sanity-plugin-taxonomy-manager 3.3.2 → 3.3.3
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.esm.esm.js +1 -1
- package/lib/index.esm.esm.js.map +1 -1
- package/lib/index.esm.mjs +1 -1
- package/lib/index.esm.mjs.map +1 -1
- package/lib/index.js +1 -1
- package/lib/index.js.map +1 -1
- package/package.json +1 -1
- package/src/skosConcept.tsx +2 -2
package/lib/index.esm.esm.js
CHANGED
|
@@ -138,4 +138,4 @@ import{useFormValue as e,set as t,useDocumentStore as n,useClient as r,useColorS
|
|
|
138
138
|
&:hover {
|
|
139
139
|
text-decoration: underline;
|
|
140
140
|
}
|
|
141
|
-
`,ar=Zn.p``;const sr=e=>{const{onChange:n}=e,r=j(),o=A((()=>{n(t(I(6))),r.push({status:"success",title:"Identifier created.",closable:!0})}),[n,r]);return u(D,{space:2,children:u(F,{space:[3,3,4],children:u(U,{tone:"primary",fontSize:2,onClick:o,text:"Generate Identifier"})})})};var cr=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},lr={},dr={},pr={};Object.defineProperty(pr,"__esModule",{value:!0});var hr="image-Tb9Ew8CXIwaY6R1kjMvI0uRR-2000x3000-jpg";pr.default=function(e){var t=e.split("-"),n=t[1],r=t[2],o=t[3];if(!n||!r||!o)throw new Error("Malformed asset _ref '".concat(e,"'. Expected an id like \"").concat(hr,'".'));var i=r.split("x"),a=+i[0],s=+i[1];if(!(isFinite(a)&&isFinite(s)))throw new Error("Malformed asset _ref '".concat(e,"'. Expected an id like \"").concat(hr,'".'));return{id:n,width:a,height:s,format:o}};var ur={},fr=cr&&cr.__assign||function(){return fr=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},fr.apply(this,arguments)};Object.defineProperty(ur,"__esModule",{value:!0});function mr(e){var t=e.split("/").slice(-1);return"image-".concat(t[0]).replace(/\.([a-z]+)$/,"-$1")}ur.default=function(e){if(!e)return null;var t,n;if("string"==typeof e&&/^https?:\/\//.test("".concat(e)))t={asset:{_ref:mr(e)}};else if("string"==typeof e)t={asset:{_ref:e}};else if((n=e)&&"string"==typeof n._ref)t={asset:e};else if(function(e){return!!e&&"string"==typeof e._id}(e))t={asset:{_ref:e._id||""}};else if(function(e){var t=e;return!(!t||!t.asset)&&"string"==typeof t.asset.url}(e))t={asset:{_ref:mr(e.asset.url)}};else{if("object"!=typeof e.asset)return null;t=fr({},e)}var r=e;return r.crop&&(t.crop=r.crop),r.hotspot&&(t.hotspot=r.hotspot),function(e){if(e.crop&&e.hotspot)return e;var t=fr({},e);return t.crop||(t.crop={left:0,top:0,bottom:0,right:0}),t.hotspot||(t.hotspot={x:.5,y:.5,height:1,width:1}),t}(t)},function(e){var t=cr&&cr.__assign||function(){return t=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},t.apply(this,arguments)},n=cr&&cr.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(e,"__esModule",{value:!0}),e.parseSource=e.SPEC_NAME_TO_URL_NAME_MAPPINGS=void 0;var r=n(pr),o=n(ur);e.parseSource=o.default,e.SPEC_NAME_TO_URL_NAME_MAPPINGS=[["width","w"],["height","h"],["format","fm"],["download","dl"],["blur","blur"],["sharpen","sharp"],["invert","invert"],["orientation","or"],["minHeight","min-h"],["maxHeight","max-h"],["minWidth","min-w"],["maxWidth","max-w"],["quality","q"],["fit","fit"],["crop","crop"],["saturation","sat"],["auto","auto"],["dpr","dpr"],["pad","pad"]],e.default=function(n){var i=t({},n||{}),a=i.source;delete i.source;var s=(0,o.default)(a);if(!s)throw new Error("Unable to resolve image URL from source (".concat(JSON.stringify(a),")"));var c=s.asset._ref||s.asset._id||"",l=(0,r.default)(c),d=Math.round(s.crop.left*l.width),p=Math.round(s.crop.top*l.height),h={left:d,top:p,width:Math.round(l.width-s.crop.right*l.width-d),height:Math.round(l.height-s.crop.bottom*l.height-p)},u=s.hotspot.height*l.height/2,f=s.hotspot.width*l.width/2,m=s.hotspot.x*l.width,g=s.hotspot.y*l.height,y={left:m-f,top:g-u,right:m+f,bottom:g+u};return i.rect||i.focalPoint||i.ignoreImageParams||i.crop||(i=t(t({},i),function(e,t){var n,r=t.width,o=t.height;if(!r||!o)return{width:r,height:o,rect:e.crop};var i=e.crop,a=e.hotspot,s=r/o,c=i.width/i.height;if(c>s){var l=Math.round(i.height),d=Math.round(l*s),p=Math.max(0,Math.round(i.top)),h=Math.round((a.right-a.left)/2+a.left);(u=Math.max(0,Math.round(h-d/2)))<i.left?u=i.left:u+d>i.left+i.width&&(u=i.left+i.width-d),n={left:u,top:p,width:d,height:l}}else{d=i.width,l=Math.round(d/s);var u=Math.max(0,Math.round(i.left)),f=Math.round((a.bottom-a.top)/2+a.top),m=Math.max(0,Math.round(f-l/2));m<i.top?m=i.top:m+l>i.top+i.height&&(m=i.top+i.height-l),n={left:u,top:m,width:d,height:l}}return{width:r,height:o,rect:n}}({crop:h,hotspot:y},i))),function(t){var n=(t.baseUrl||"https://cdn.sanity.io").replace(/\/+$/,""),r="".concat(t.asset.id,"-").concat(t.asset.width,"x").concat(t.asset.height,".").concat(t.asset.format),o="".concat(n,"/images/").concat(t.projectId,"/").concat(t.dataset,"/").concat(r),i=[];if(t.rect){var a=t.rect,s=a.left,c=a.top,l=a.width,d=a.height;(0!==s||0!==c||d!==t.asset.height||l!==t.asset.width)&&i.push("rect=".concat(s,",").concat(c,",").concat(l,",").concat(d))}t.bg&&i.push("bg=".concat(t.bg)),t.focalPoint&&(i.push("fp-x=".concat(t.focalPoint.x)),i.push("fp-y=".concat(t.focalPoint.y)));var p=[t.flipHorizontal&&"h",t.flipVertical&&"v"].filter(Boolean).join("");return p&&i.push("flip=".concat(p)),e.SPEC_NAME_TO_URL_NAME_MAPPINGS.forEach((function(e){var n=e[0],r=e[1];typeof t[n]<"u"?i.push("".concat(r,"=").concat(encodeURIComponent(t[n]))):typeof t[r]<"u"&&i.push("".concat(r,"=").concat(encodeURIComponent(t[r])))})),0===i.length?o:"".concat(o,"?").concat(i.join("&"))}(t(t({},i),{asset:l}))}}(dr);var gr=cr&&cr.__assign||function(){return gr=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},gr.apply(this,arguments)},yr=cr&&cr.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n),Object.defineProperty(e,r,{enumerable:!0,get:function(){return t[n]}})}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),br=cr&&cr.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),vr=cr&&cr.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)"default"!==n&&Object.prototype.hasOwnProperty.call(e,n)&&yr(t,e,n);return br(t,e),t};Object.defineProperty(lr,"__esModule",{value:!0}),lr.ImageUrlBuilder=void 0;var wr=vr(dr),Cr=["clip","crop","fill","fillmax","max","scale","min"],_r=["top","bottom","left","right","center","focalpoint","entropy"],Sr=["format"];function kr(e){for(var t=0,n=wr.SPEC_NAME_TO_URL_NAME_MAPPINGS;t<n.length;t++){var r=n[t],o=r[0],i=r[1];if(e===o||e===i)return o}return e}lr.default=function(e){if(function(e){return!(!e||!("config"in e))&&"function"==typeof e.config}(e)){var t=e.config(),n=t.apiHost,r=t.projectId,o=t.dataset;return new Ir(null,{baseUrl:(n||"https://api.sanity.io").replace(/^https:\/\/api\./,"https://cdn."),projectId:r,dataset:o})}var i=e;if(function(e){return!(!e||!("clientConfig"in e))&&"object"==typeof e.clientConfig}(i)){var a=i.clientConfig;n=a.apiHost,r=a.projectId,o=a.dataset;return new Ir(null,{baseUrl:(n||"https://api.sanity.io").replace(/^https:\/\/api\./,"https://cdn."),projectId:r,dataset:o})}return new Ir(null,e)};var Ir=function(){function e(e,t){this.options=gr(e?gr({},e.options||{}):{},t||{})}return e.prototype.withOptions=function(t){var n=t.baseUrl||this.options.baseUrl,r={baseUrl:n};for(var o in t)if(t.hasOwnProperty(o)){r[kr(o)]=t[o]}return new e(this,gr({baseUrl:n},r))},e.prototype.image=function(e){return this.withOptions({source:e})},e.prototype.dataset=function(e){return this.withOptions({dataset:e})},e.prototype.projectId=function(e){return this.withOptions({projectId:e})},e.prototype.bg=function(e){return this.withOptions({bg:e})},e.prototype.dpr=function(e){return this.withOptions(e&&1!==e?{dpr:e}:{})},e.prototype.width=function(e){return this.withOptions({width:e})},e.prototype.height=function(e){return this.withOptions({height:e})},e.prototype.focalPoint=function(e,t){return this.withOptions({focalPoint:{x:e,y:t}})},e.prototype.maxWidth=function(e){return this.withOptions({maxWidth:e})},e.prototype.minWidth=function(e){return this.withOptions({minWidth:e})},e.prototype.maxHeight=function(e){return this.withOptions({maxHeight:e})},e.prototype.minHeight=function(e){return this.withOptions({minHeight:e})},e.prototype.size=function(e,t){return this.withOptions({width:e,height:t})},e.prototype.blur=function(e){return this.withOptions({blur:e})},e.prototype.sharpen=function(e){return this.withOptions({sharpen:e})},e.prototype.rect=function(e,t,n,r){return this.withOptions({rect:{left:e,top:t,width:n,height:r}})},e.prototype.format=function(e){return this.withOptions({format:e})},e.prototype.invert=function(e){return this.withOptions({invert:e})},e.prototype.orientation=function(e){return this.withOptions({orientation:e})},e.prototype.quality=function(e){return this.withOptions({quality:e})},e.prototype.forceDownload=function(e){return this.withOptions({download:e})},e.prototype.flipHorizontal=function(){return this.withOptions({flipHorizontal:!0})},e.prototype.flipVertical=function(){return this.withOptions({flipVertical:!0})},e.prototype.ignoreImageParams=function(){return this.withOptions({ignoreImageParams:!0})},e.prototype.fit=function(e){if(-1===Cr.indexOf(e))throw new Error('Invalid fit mode "'.concat(e,'"'));return this.withOptions({fit:e})},e.prototype.crop=function(e){if(-1===_r.indexOf(e))throw new Error('Invalid crop mode "'.concat(e,'"'));return this.withOptions({crop:e})},e.prototype.saturation=function(e){return this.withOptions({saturation:e})},e.prototype.auto=function(e){if(-1===Sr.indexOf(e))throw new Error('Invalid auto mode "'.concat(e,'"'));return this.withOptions({auto:e})},e.prototype.pad=function(e){return this.withOptions({pad:e})},e.prototype.url=function(){return(0,wr.default)(this.options)},e.prototype.toString=function(){return this.url()},e}();lr.ImageUrlBuilder=Ir,(cr&&cr.__importDefault||function(e){return e&&e.__esModule?e:{default:e}})(lr);const xr={},Nr={apiVersion:"v2023-05-01"},Or=null;function Er(e){const t=M((()=>JSON.stringify(e||{})),[e]);return M((()=>JSON.parse(t)),[t])}function Pr(e,t){let{params:r=xr,options:o=Nr,initialValue:i=Or}=t;const[a,s]=V(!0),[c,l]=V(!1),[d,p]=V(i),h=Er(r),u=Er(o),f=E(null),m=n();return R((()=>{if(e&&!c&&!f.current)try{f.current=m.listenQuery(e,h,u).pipe(ne(te),re((e=>(console.error(e),l(e),s(!1),p(null),e)))).subscribe((e=>{p((t=>te(t,e)?t:e)),s(!1),l(!1)}))}catch(e){console.error(e),s(!1),l(e)}return c&&f.current&&f.current.unsubscribe(),()=>{var e;f.current&&(null==(e=f?.current)||e.unsubscribe(),f.current=null)}}),[e,c,h,u,m]),{data:d,loading:a,error:c}}var Tr,$r,Ar,Vr=Object.freeze,Rr=Object.defineProperty,Mr=(e,t)=>Vr(Rr(e,"raw",{value:Vr(e.slice())}));Zn((function(){return u(B,{as:"table",...arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}})}))((()=>Bn(Tr||(Tr=Mr(["\n display: table;\n width: 100%;\n border-collapse: collapse;\n\n &:not([hidden]) {\n display: table;\n border-collapse: collapse;\n }\n "])))));Zn((function(){return u(B,{as:"tr",...arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}})}))((()=>Bn($r||($r=Mr(["\n display: table-row;\n\n &:not([hidden]) {\n display: table-row;\n }\n "])))));Zn((function(){return u(B,{as:"td",...arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}})}))((()=>Bn(Ar||(Ar=Mr(["\n display: table-cell;\n\n &:not([hidden]) {\n display: table-cell;\n }\n "])))));const zr=(e=1)=>e>6?"":`"childConcepts": *[\n (\n (\n _id in $draftConceptIds &&\n !(conceptId in *[_id in $conceptIds].conceptId)\n ) \n ||\n (\n _id in $conceptIds &&\n !(conceptId in $draftConceptIds)\n )\n ) && ^._id in broader[]._ref ]|order(prefLabel){\n "id": _id,\n "level": ${e},\n prefLabel,\n definition,\n example,\n scopeNote,\n ${zr(e+1)}\n }`,Hr=(e=1)=>e>6?"":`"childConcepts": *[_id in *[_id == $id][0].concepts[]._ref && ^._id in broader[]._ref ]|order(prefLabel){\n "id": _id,\n "level": ${e},\n prefLabel,\n definition,\n example,\n scopeNote,\n ${Hr(e+1)}\n }`,Dr=z(null),Lr=z({editControls:!1});function jr(e){const t=j(),n=r({apiVersion:"2021-10-21"}),o=function(){const e=$(oe),{routerPanesState:t,groupIndex:n}=d();return A((r=>{if(!e||!r)return;const o=[...t];o.splice(n+1,n+1,[{id:r,params:{type:"skosConcept"}}]);const i=e.resolvePathFromState({panes:o});e.navigateUrl({path:i})}),[e,t,n])}(),i=e.displayed.baseIri;return A(((r,a,s)=>{let c;c=a?{_id:`drafts.${I()}`,_type:"skosConcept",conceptId:`${I(6)}`,prefLabel:"",baseIri:i,broader:[a&&{_key:I(6),_ref:a,_type:"reference"}],related:[]}:{_id:`drafts.${I()}`,_type:"skosConcept",conceptId:`${I(6)}`,prefLabel:"",baseIri:i,broader:[],related:[]};const l=JSON.parse(JSON.stringify(e.displayed));l._id.includes("drafts.")||(l._id=`drafts.${l._id}`),n.transaction().createIfNotExists(l).create(c).patch(l._id,(e=>"topConcept"==r?e.setIfMissing({topConcepts:[]}).append("topConcepts",[{_ref:c._id.replace("drafts.",""),_type:"reference",_key:I(6),_weak:!0,_strengthenOnPublish:{_type:"skosConcept",weak:!0,template:{id:"skosConcept",params:"undefined"}}}]):e.setIfMissing({concepts:[]}).insert("after","concepts[-1]",[{_ref:c._id.replace("drafts.",""),_type:"reference",_key:I(6),_weak:!0,_strengthenOnPublish:{_type:"skosConcept",weak:void 0,template:{id:"skosConcept",params:"undefined"}}}]))).commit({autoGenerateArrayKeys:!0}).then((e=>{t.push({closable:!0,status:"success",title:"Created new concept"}),o(c._id)})).catch((e=>{t.push({closable:!0,status:"error",title:"Error creating concept",description:e.message})}))}),[e.displayed,n,i,t,o])}function Fr(e){const t=j(),n=r({apiVersion:"2021-10-21"});return A(((r,o,i)=>{const a="topConcept"==o?"topConcepts":"concepts",s=JSON.parse(JSON.stringify(e.displayed));s._id.includes("drafts.")||(s._id=`drafts.${s._id}`),n.transaction().createIfNotExists(s).patch(s._id,(e=>e.unset([`${a}[_ref=="${r.replace("drafts.","")}"]`]))).commit().then((e=>{t.push({closable:!0,status:"success",title:(i?`"${i}"`:"Concept")+" removed from scheme"})})).catch((e=>{t.push({closable:!0,status:"error",title:"Error removing concept",description:e.message})}))}),[n,e.displayed,t])}function Ur(){return"dark"==o()?H.gray[50].hex:H.gray[800].hex}function Br({concept:e}){const t=$(oe),{routerPanesState:n,groupIndex:r}=d(),o=Ur(),{id:i,prefLabel:a}=e??{},s=A((()=>{if(!t||!i)return;const e=[...n];e.splice(r+1,r+1,[{id:i,params:{type:"skosConcept"}}]);const o=t.resolvePathFromState({panes:e});t.navigateUrl({path:o})}),[i,t,n,r]);return u(ir,{href:"#",onClick:s,style:{color:o},children:a})}const qr=({concept:e})=>{const[t,n]=V(!1),r=A((()=>n(!1)),[]),o=A((()=>n(!0)),[]),i=Ur();return e&&(e.definition||e.example||e.scopeNote)?h(f,{children:[u(Qn,{className:"action","aria-label":"info",onClick:o,type:"button",children:u(m,{className:"info",style:{color:i}})}),t&&u(q,{header:e.prefLabel,id:"dialog-example",onClose:r,zOffset:1e3,width:1,children:u(G,{padding:4,paddingBottom:5,children:h(D,{space:4,children:[e.definition&&h(D,{space:2,children:[u(Z,{size:1,children:"Definition"}),u(L,{size:2,muted:!0,style:{whiteSpace:"pre-wrap"},children:e.definition})]}),e.example&&h(D,{space:2,children:[u(Z,{size:1,children:"Example"}),u(L,{size:2,muted:!0,style:{whiteSpace:"pre-wrap"},children:e.example})]}),e.scopeNote&&h(D,{space:2,children:[u(Z,{size:1,children:"Scope Note"}),u(L,{size:2,muted:!0,style:{whiteSpace:"pre-wrap"},children:e.scopeNote})]})]})})})]}):null};function Gr({concept:e,selectConcept:t}){const{prefLabel:n,id:r}=e??{},o=Ur(),i=A((()=>{t({_ref:r,_type:"reference"})}),[r,t]);return u(f,{children:t?u(ir,{href:"#",onClick:i,style:{color:o},children:n}):u(ar,{children:n})})}const Zr=({concept:e,selectConcept:t,inputComponent:n=!1})=>{const r=$(Dr)||{},{globalVisibility:{treeVisibility:o}}=$(Lr)||{},{editControls:i}=$(Lr)||{editControls:!1},a=jr(r),s=Fr(r),c=A((()=>{a("concept",e?.id,e?.prefLabel)}),[e?.id,e?.prefLabel,a]),l=A((()=>{s(e.id,"concept",e?.prefLabel)}),[e.id,e?.prefLabel,s]),[d,p]=V(o),f=A((()=>{"open"==d?p("closed"):"closed"==d&&p("open")}),[d]);return h(or,{className:d,children:[h(F,{space:2,children:[h(F,{space:1,children:[h(F,{space:1,children:[e?.childConcepts&&e.childConcepts.length>0&&u(er,{onClick:f,type:"button","aria-expanded":"open"==d,children:u(g,{})}),e?.childConcepts&&0==e.childConcepts.length&&u(y,{className:"spacer"}),!e?.prefLabel&&u("span",{className:"untitled",children:"[new concept]"}),n?u(Gr,{concept:e,selectConcept:t}):u(Br,{concept:e})]}),!i&&u(qr,{concept:e})]}),i&&e?.level&&e.level<5&&h(F,{space:2,children:[u(Qn,{onClick:c,type:"button",className:"action","aria-label":"Add child a child concept",children:u(b,{className:"add"})}),u(Qn,{onClick:l,type:"button",className:"action","aria-label":"Remove concept from scheme",children:u(v,{className:"remove"})})]}),i&&0==e.childConcepts?.length&&5==e.level&&h(F,{space:2,children:[u(W,{content:u(G,{padding:2,sizing:"border",children:u(D,{padding:1,space:2,children:u(L,{muted:!0,size:1,children:"This concept is at the maximum Taxonomy Manager hierarchy depth of 5 levels."})})}),fallbackPlacements:["right","left"],placement:"top",children:u(m,{className:"info warning"})}),u(Qn,{onClick:l,type:"button",className:"action","aria-label":"Remove concept from scheme",children:u(v,{className:"remove"})})]}),e?.childConcepts&&e?.childConcepts?.length>0&&5==e.level&&h(F,{space:1,children:[u(W,{content:u(G,{padding:2,sizing:"border",children:h(D,{padding:1,space:2,children:[u(L,{muted:!0,size:1,children:"This concept has unlisted child concepts."}),u(L,{muted:!0,size:1,children:"The maximum hierarchy depth is 5 levels."})]})}),fallbackPlacements:["right","left"],placement:"top",children:u(w,{className:"info error"})}),r.displayed?.controls&&u(Qn,{onClick:l,type:"button",className:"action","aria-label":"Remove concept from scheme",children:u(v,{className:"remove"})})]})]}),e?.childConcepts&&e.childConcepts.length>0&&e?.level&&e.level<5&&u(Wr,{concepts:e.childConcepts,selectConcept:t,inputComponent:n})]})},Wr=({concepts:e,inputComponent:t=!1,selectConcept:n})=>u(rr,{children:e.map((e=>u(Zr,{concept:e,selectConcept:n,inputComponent:t},e.id)))}),Yr=({concept:e,treeVisibility:t,inputComponent:n,selectConcept:r})=>{const o=$(Dr)||{},{editControls:i}=$(Lr)||{editControls:!1},a=jr(o),s=Fr(o),[c,l]=V(t),d=A((()=>{"open"==c?l("closed"):"closed"==c&&l("open")}),[c]),p=A((()=>{a("concept",e?.id,e?.prefLabel)}),[e?.id,e?.prefLabel,a]),f=A((()=>{s(e?.id,"topConcept",e?.prefLabel)}),[e?.id,e?.prefLabel,s]);return h(tr,{className:c,children:[h(F,{space:2,children:[h(F,{space:0,children:[e?.childConcepts&&e.childConcepts.length>0&&u(er,{onClick:d,type:"button","aria-expanded":"open"==c,children:u(g,{})}),e?.childConcepts&&0==e.childConcepts.length&&u(y,{className:"spacer"}),!e?.prefLabel&&u("span",{className:"untitled",children:"[new concept]"}),n?u(Gr,{concept:e,selectConcept:r}):u(Br,{concept:e})]}),u(L,{size:1,muted:!0,children:"top concept"}),!i&&u(qr,{concept:e}),i&&h(F,{space:2,children:[u(W,{content:u(G,{padding:2,sizing:"border",children:u(D,{padding:1,space:2,children:u(L,{muted:!0,size:1,children:"Add a child concept"})})}),fallbackPlacements:["right","left"],placement:"top",children:u(Qn,{onClick:p,type:"button",className:"action","aria-label":"Add child a child concept",children:u(b,{className:"add"})})}),u(W,{content:u(G,{padding:2,sizing:"border",children:u(D,{padding:1,space:2,children:u(L,{muted:!0,size:1,children:"Remove concept from scheme"})})}),fallbackPlacements:["right","left"],placement:"top",children:u(Qn,{onClick:f,type:"button",className:"action","aria-label":"Remove concept from scheme",children:u(v,{className:"remove"})})})]})]}),e?.childConcepts&&e.childConcepts.length>0&&u(Wr,{concepts:e.childConcepts,selectConcept:r,inputComponent:n})]})},Kr=({concept:e,treeVisibility:t,inputComponent:n,selectConcept:r})=>{const o=$(Dr)||{},{editControls:i}=$(Lr)||{editControls:!1},a=jr(o),s=Fr(o),[c,l]=V(t),d=A((()=>{"open"==c?l("closed"):"closed"==c&&l("open")}),[c]),p=A((()=>{a("concept",e?.id,e?.prefLabel)}),[e?.id,e?.prefLabel,a]),f=A((()=>{s(e.id,"concept",e?.prefLabel)}),[e.id,e?.prefLabel,s]);return h(nr,{className:c,children:[h(F,{space:2,children:[e?.childConcepts&&e.childConcepts.length>0&&u(er,{onClick:d,type:"button","aria-expanded":"open"==c,children:u(g,{})}),e?.childConcepts&&0==e.childConcepts.length&&u(y,{className:"spacer"}),!e?.prefLabel&&u("span",{className:"untitled",children:"[new concept]"}),n?u(Gr,{concept:e,selectConcept:r}):u(Br,{concept:e}),o.displayed?.topConcepts?.length>0&&u(L,{size:1,muted:!0,children:"orphan"}),!i&&u(qr,{concept:e}),!n&&i&&h(F,{space:2,children:[u(W,{content:u(G,{padding:2,sizing:"border",children:u(D,{padding:1,space:2,children:u(L,{muted:!0,size:1,children:"Add a child concept"})})}),fallbackPlacements:["right","left"],placement:"top",children:u(Qn,{onClick:p,type:"button",className:"action","aria-label":"Add child a child concept",children:u(b,{className:"add"})})}),u(W,{content:u(G,{padding:2,sizing:"border",children:u(D,{padding:1,space:2,children:u(L,{muted:!0,size:1,children:"Remove concept from scheme"})})}),fallbackPlacements:["right","left"],placement:"top",children:u(Qn,{onClick:f,type:"button",className:"action","aria-label":"Remove concept from scheme",children:u(v,{className:"remove"})})})]})]}),e?.childConcepts&&e.childConcepts.length>0&&u(Wr,{concepts:e.childConcepts,selectConcept:r,inputComponent:n})]})},Xr=({document:e})=>{const[t,n]=V(!1),[o,i]=V(""),[a,s]=V(""),c=A((()=>n(!1)),[]),l=A((()=>n(!0)),[]),d=A((e=>{i(e.currentTarget.value)}),[]),p=A((e=>{s(e.currentTarget.value)}),[]),f=function(){const e=j(),t=r({apiVersion:"2021-10-21"});return A(((n,r,o)=>{const i=n.displayed?._id,a=n.displayed?.baseIri,s=n.displayed?.schemeId,c={_id:`drafts.${i}`,_type:"skosConceptScheme",schemeId:s,baseIri:a,title:r,description:o||""};t.createIfNotExists(c).then((t=>o?e.push({closable:!0,status:"success",title:"Title and Description added."}):e.push({closable:!0,status:"success",title:"Title added."}))).catch((t=>{e.push({closable:!0,status:"error",title:"There has been an error",description:t.message})}))}),[t,e])}(),m=A((()=>{f(e,o,a)}),[f,a,e,o]);return h(Kn,{children:[u(B,{padding:[3,3,4],radius:2,shadow:1,tone:"primary",children:h(D,{space:6,children:[h(D,{space:4,children:[u(Z,{size:4,children:"New Concept Scheme"}),u(L,{size:2,children:'To start using hierarchy view taxonomy builder, first give your concept scheme a name and optional description. You can also use the "Editor" tab to add concepts to the tree manually.'})]}),u(U,{tone:"primary",fontSize:2,icon:C,onClick:l,text:"Add Title"})]})}),t&&u(q,{header:"Title & Description",id:"title-description",onClose:c,zOffset:1e3,width:1,children:u(G,{padding:4,children:h(D,{space:4,children:[h(D,{space:2,children:[u(Z,{size:1,children:"Title"}),u(L,{size:1,muted:!0,children:"Describe the concept scheme in one or two words."})]}),u(Y,{fontSize:2,onChange:d,padding:3,placeholder:"",value:o}),h(D,{space:2,children:[u(Z,{size:1,children:"Description (optional)"}),u(L,{size:1,muted:!0,children:"Describe the intended use of this concept scheme."})]}),u(K,{fontSize:2,onChange:p,padding:3,placeholder:"",value:a,rows:3}),u(U,{tone:"primary",fontSize:2,onClick:m,text:"Save"})]})})})]})},Jr=()=>u(Kn,{children:u(B,{padding:[3,3,4],radius:2,shadow:1,tone:"primary",children:h(D,{space:4,children:[u(Z,{size:4,children:"No Concepts"}),u(L,{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 children to them. To create a flat list of concepts, create Entry Concepts directly."})]})})}),Qr=({concepts:e,inputComponent:t,selectConcept:n})=>{const{globalVisibility:{treeId:r,treeVisibility:o}={treeId:123,treeVisibility:"open"},setEditControls:i=()=>{console.warn("setEditControls not defined")}}=$(Lr)||{};return R((()=>{e?.topConcepts&&0===e.topConcepts.length&&e?.orphans&&0===e.orphans.length&&i(!0)}),[e.topConcepts,e.orphans,i]),e?.topConcepts&&0===e.topConcepts.length&&e?.orphans&&0===e.orphans.length?u(Jr,{}):h(Xn,{children:[e.topConcepts&&e.topConcepts.map((e=>u(Yr,{concept:e,treeVisibility:o,inputComponent:t,selectConcept:n},e?.id+r))),e.orphans.map((e=>u(Kr,{concept:e,treeVisibility:o,inputComponent:t,selectConcept:n},e.id+r)))]})},eo=({branchId:e="",selectConcept:t,inputComponent:n})=>{const r=$(Dr)||{},o=r.displayed?._id,{data:i,loading:a,error:s}=Pr({fetch:`\n select($branchId != null => \n *[_id == $id][0] {\n _updatedAt,\n "topConcepts":*[_type == "skosConcept" && conceptId == $branchId]{\n "id": _id,\n "level": 0,\n prefLabel,\n definition,\n example,\n scopeNote,\n ${Hr()}\n }, \n "orphans": []\n },\n *[_id == $id][0] {\n _updatedAt,\n "topConcepts":topConcepts[]->|order(prefLabel){\n "id": _id,\n "level": 0,\n prefLabel,\n definition,\n example,\n scopeNote,\n ${Hr()}\n }, \n "orphans": *[\n _id in coalesce(*[_id == 'drafts.' + $id][0], *[_id == $id][0]).concepts[]._ref &&\n count((broader[]._ref) [@ in coalesce(*[_id == 'drafts.' + $id][0], *[_id == $id][0]).topConcepts[]._ref]) < 1 &&\n count((broader[]._ref) [@ in coalesce(*[_id == 'drafts.' + $id][0], *[_id == $id][0]).concepts[]._ref]) < 1\n ]|order(prefLabel){\n "id": _id,\n "level": 0,\n prefLabel,\n definition,\n example,\n scopeNote,\n ${Hr()}\n }\n }\n )`,listen:'*[_type == "skosConcept" || _id == $id]'},{params:{id:o,branchId:e}});return a?u(G,{padding:5,children:h(X,{align:"center",direction:"column",gap:5,height:"fill",justify:"center",style:{paddingTop:"1rem"},children:[u(J,{muted:!0}),u(L,{muted:!0,size:1,children:"Loading hierarchy…"})]})}):s?(console.warn(s),u(G,{padding:4,children:u(B,{padding:[3],radius:2,shadow:1,tone:"caution",children:u(L,{size:1,children:"There was a problem loading terms. Please check the scheme configuration and try again."})})})):i?u(Lr.Provider,{value:{globalVisibility:{treeId:"123",treeVisibility:"open"}},children:u(G,{padding:4,children:u(Qr,{concepts:i,inputComponent:n,selectConcept:t})})}):u(Xr,{document:r})},to=({branchId:e="",selectConcept:t,inputComponent:n=!1})=>{const r=$(Dr)||{},o=r.displayed?._id,i=r.displayed?.concepts?.map((e=>e?._ref))||[],a=r.displayed?.concepts?.map((e=>`drafts.${e?._ref}`))||[],s=r.displayed?.topConcepts?.map((e=>e?._ref))||[],c=r.displayed?.topConcepts?.map((e=>`drafts.${e?._ref}`))||[],l=jr(r),d=A((()=>{l("topConcept")}),[l]),p=A((()=>{l("concept")}),[l]),[m,g]=V({treeId:I(3),treeVisibility:"open"}),[y,v]=V(!1);R((()=>{r.displayed._id.includes("drafts.")||v(!1)}),[r.displayed._id]);const w=A((()=>{g({treeId:I(3),treeVisibility:"open"})}),[]),C=A((()=>{g({treeId:I(3),treeVisibility:"closed"})}),[]),k=A((()=>{v(!0)}),[]),x=A((()=>{v(!1)}),[]),{data:N,loading:O,error:E}=Pr({fetch:`*[_id == $id][0] {\n _updatedAt,\n "topConcepts": *[\n (\n _id in $draftTopConceptIds &&\n !(conceptId in *[_id in $topConceptIds].conceptId)\n )\n ||\n (\n _id in $topConceptIds\n )\n ]|order(prefLabel) {\n "id": _id,\n "level": 0,\n prefLabel,\n definition,\n example,\n scopeNote,\n ${zr()}\n },\n "orphans": *[\n ((\n _id in $draftConceptIds &&\n !(conceptId in *[_id in $conceptIds].conceptId)\n )\n ||\n (\n _id in $conceptIds\n )) &&\n count(\n (broader[]._ref) [@ in coalesce(\n *[_id == 'drafts.' + $id][0], \n *[_id == $id][0]\n ).topConcepts[]._ref]) < 1 &&\n count(\n (broader[]._ref) [@ in coalesce(\n *[_id == 'drafts.' + $id][0], \n *[_id == $id][0]\n ).concepts[]._ref]) < 1\n ]|order(prefLabel){\n "id": _id,\n "level": 0,\n prefLabel,\n definition,\n example,\n scopeNote,\n ${zr()}\n }\n }`,listen:'*[_type == "skosConcept" || _id == $id ]'},{params:{id:o,branchId:e,conceptIds:i,draftConceptIds:a,topConceptIds:s,draftTopConceptIds:c}});return O?u(G,{padding:5,children:h(X,{align:"center",direction:"column",gap:5,height:"fill",justify:"center",style:{paddingTop:"1rem"},children:[u(J,{muted:!0}),u(L,{muted:!0,size:1,children:"Loading hierarchy…"})]})}):E?(console.error(E),u("div",{children:"Error here"})):N?u(Lr.Provider,{value:{globalVisibility:m,editControls:y,setEditControls:v},children:u(G,{padding:4,paddingTop:2,children:h(f,{children:[u(D,{space:4,children:u(B,{borderBottom:!0,paddingBottom:1,display:"flex",flex:1,children:h(X,{justify:"space-between",flex:1,children:[u(B,{children:(N.topConcepts?.filter((e=>(e?.childConcepts?.length??0)>0)).length>0||N.orphans?.filter((e=>(e?.childConcepts?.length??0)>0)).length>0)&&h(F,{space:1,children:[u(Jn,{type:"button",onClick:C,children:u(L,{weight:"semibold",muted:!0,size:1,children:"Collapse"})}),u(L,{weight:"semibold",muted:!0,size:1,children:"|"}),u(Jn,{type:"button",onClick:w,children:u(L,{weight:"semibold",muted:!0,size:1,children:"Expand"})})]})}),u(B,{children:y?h(F,{space:1,children:[u(Jn,{type:"button",className:"add",onClick:d,children:h(L,{weight:"semibold",muted:!0,size:1,children:[u(b,{})," Add Top Concept"]})}),u(Jn,{type:"button",className:"add",onClick:p,children:h(L,{weight:"semibold",muted:!0,size:1,children:[u(b,{})," Add Concept"]})}),u(Jn,{type:"button",onClick:x,children:h(L,{weight:"semibold",muted:!0,size:1,children:[u(_,{})," Done"]})})]}):u(F,{space:2,children:u(Jn,{type:"button",onClick:k,children:h(L,{weight:"semibold",muted:!0,size:1,children:[u(S,{})," Edit"]})})})})]})})}),u(Qr,{concepts:N,inputComponent:n,selectConcept:t})]})})}):u(Xr,{document:r})},no=({document:e,branchId:t,selectConcept:n,inputComponent:r=!1})=>u(Dr.Provider,{value:e,children:r?u(eo,{inputComponent:r,branchId:t,selectConcept:n}):h(Q,{width:1,style:{paddingTop:"1.25rem"},children:[e?.displayed?.description&&u(G,{padding:4,children:u(D,{space:4,children:h(D,{space:2,children:[u(L,{size:1,weight:"semibold",children:"Description"}),u(L,{size:2,muted:!0,style:{whiteSpace:"pre-wrap"},children:e?.displayed.description})]})})}),u(to,{inputComponent:r,branchId:t})]})});function ro(t){const{name:n,title:o}=t,i=e(["_id"]),a=r({apiVersion:"2021-10-21"}),[s,c]=V(!0),[l,d]=V(!0),[p,f]=V(!1),[m,g]=V({}),[y,b]=V(null),{schemeId:v,branchId:w=null}=y?.params||{},{filter:C}=t.schemaType.options;R((()=>{!async function(){try{const e=await C({getClient:()=>a});b(e),d(!1)}catch(e){console.error("Error fetching filter values: ",e)}}()}),[C,a]),R((()=>{a.fetch(`{"displayed": *[schemeId == "${v}"][0]}`).then((e=>{e?.displayed&&(g(e),c(!1))})).catch((e=>console.warn(e)))}),[a,v]);const _=A((()=>{f(!0)}),[]),S=A((()=>{f(!1)}),[]),k=A((e=>{i.includes("drafts.")?a.patch(i).set({[n]:e}).commit().then((()=>f(!1))).catch((e=>console.error(e))):a.fetch(`*[_id == "${i}"][0]`).then((t=>{t._id=`drafts.${t._id}`,t[n]=e,a.create(t)})).then((()=>f(!1))).catch((e=>console.error(e)))}),[a,i,n]);return t.schemaType.options?.filter?0==t.schemaType.options.filter.length?h(D,{space:3,children:[t.renderDefault(t),u(G,{padding:4,children:u(B,{padding:[3],radius:2,shadow:1,tone:"caution",children:h(L,{size:1,children:["There was a problem loading your filter settings. Please check the"," ",u("code",{children:"schemeFilter()"})," or ",u("code",{children:"branchFilter()"})," configuration for the"," ",o," field."]})})})]}):s||l?u(G,{padding:5,children:h(X,{align:"center",direction:"column",gap:5,height:"fill",justify:"center",style:{paddingTop:"1rem"},children:[u(J,{muted:!0}),u(L,{muted:!0,size:1,children:"Loading input component…"})]})}):h(D,{space:3,children:[t.renderDefault(t),u(ee,{columns:1,gap:3,children:u(U,{text:"Browse Taxonomy Tree",mode:"ghost",onClick:_})}),p&&u(q,{header:o,id:"concept-select-dialog",onClose:S,zOffset:900,width:1,children:u(G,{padding:10,children:u(no,{document:m,branchId:w,inputComponent:!0,selectConcept:k})})})]}):h(D,{space:3,children:[t.renderDefault(t),u(G,{padding:4,children:u(B,{padding:[3],radius:2,shadow:1,tone:"caution",children:h(L,{size:1,children:["The ",u("code",{children:"ReferenceHierarchyInput()"})," component must be used with an accompanying"," ",u("code",{children:"schemeFilter()"})," or ",u("code",{children:"branchFilter()"}),". Please add an appropriate filter to the configuration for the ",o," field."]})})})]})}function oo(t){const{name:n,title:o,value:i=[]}=t,a=e(["_id"]),s=r({apiVersion:"2021-10-21"}),[c,l]=V(!0),[d,p]=V(!0),[f,m]=V(!1),[g,y]=V({}),[b,v]=V(null),{schemeId:w,branchId:C=null}=b?.params||{},{filter:_}=t.schemaType.of[0].options,S=j();R((()=>{!async function(){try{const e=await _({getClient:()=>s});v(e),p(!1)}catch(e){console.error("Error fetching filter values: ",e)}}()}),[_,s]),R((()=>{s.fetch(`{"displayed": *[schemeId == "${w}"][0]}`).then((e=>{e?.displayed&&(y(e),l(!1))})).catch((e=>console.warn(e)))}),[s,w]);const k=A((()=>{m(!0)}),[]),I=A((()=>{m(!1)}),[]),x=A((e=>{if(i&&i.map((e=>e._ref)).includes(e._ref))return m(!1),void S.push({status:"warning",title:"Taxonomy Term Not Added",description:"The selected concept is already included in this field.",duration:5e3,closable:!0});a.includes("drafts.")?s.patch(a).setIfMissing({[n]:[]}).append(n,[e]).commit({autoGenerateArrayKeys:!0}).then((()=>m(!1))).catch((e=>console.error(e))):s.fetch(`*[_id == "${a}"][0]`).then((e=>{e._id=`drafts.${e._id}`,s.create(e)})).then((()=>{s.patch(`drafts.${a}`).setIfMissing({[n]:[]}).append(n,[e]).commit({autoGenerateArrayKeys:!0}).then((()=>m(!1))).catch((e=>console.error(e)))})).catch((e=>console.error(e)))}),[s,a,n,i,S]);return t.schemaType.of[0].options?.filter?0==t.schemaType.of[0].options.filter.length?h(D,{space:3,children:[t.renderDefault(t),u(G,{padding:4,children:u(B,{padding:[3],radius:2,shadow:1,tone:"caution",children:h(L,{size:1,children:["There was a problem loading your filter settings. Please check the"," ",u("code",{children:"schemeFilter()"})," or ",u("code",{children:"branchFilter()"})," configuration for the"," ",o," field."]})})})]}):t.schemaType.of.length>1?h(D,{space:3,children:[t.renderDefault(t),u(B,{padding:[3],radius:2,shadow:1,tone:"caution",children:u(D,{space:4,children:h(D,{space:2,children:[u(Z,{size:2,children:"Input Component Not Supported for Multi-Schema Arrays"}),h(L,{size:1,children:["The Sanity Taxonomy Manager Hierarchy Input Component is not designed to support array inputs with more than one schema type. Please see the"," ",u("a",{href:"https://sanitytaxonomymanager.com",children:"Taxonomy Manager docs"})," for more information."]})]})})})]}):c||d?u(G,{padding:5,children:h(X,{align:"center",direction:"column",gap:5,height:"fill",justify:"center",style:{paddingTop:"1rem"},children:[u(J,{muted:!0}),u(L,{muted:!0,size:1,children:"Loading input component…"})]})}):h(D,{space:3,children:[t.renderDefault(t),u(ee,{columns:1,gap:3,children:u(U,{text:"Browse Taxonomy Tree",mode:"ghost",onClick:k})}),f&&u(q,{header:o,id:"concept-select-dialog",onClose:I,zOffset:900,width:1,children:u(G,{padding:10,children:u(no,{document:g,branchId:C,inputComponent:!0,selectConcept:x})})})]}):h(D,{space:3,children:[t.renderDefault(t),u(G,{padding:4,children:u(B,{padding:[3],radius:2,shadow:1,tone:"caution",children:h(L,{size:1,children:["The ",u("code",{children:"ArrayHierarchyInput()"})," component must be used with an accompanying"," ",u("code",{children:"schemeFilter()"})," or ",u("code",{children:"branchFilter()"}),". Please add an appropriate filter to the configuration for the ",o," field."]})})})]})}const io=e=>{const{onChange:t}=e,n=j(),r=A((()=>{t(i()),n.push({status:"success",title:"Value removed.",duration:2500,closable:!0})}),[t,n]);return u(D,{space:2,children:h(F,{space:[3,3,4],children:[e.renderDefault(e),u(U,{tone:"primary",fontSize:2,onClick:r,text:"Remove Value"})]})})};var ao=[a({name:"baseIri",title:"Base URI",type:"url",validation:e=>e.required().error("Please supply a base URI in the format 'http://example.com/'"),description:h(Yn,{children:[u("summary",{children:"The root URI (Uniform Resource Identifier) used to create unique concept identifiers."}),h("div",{children:["Unique identifiers allow for the clear an unambiguous identification of concepts across namespaces, for example between ",u("code",{children:"https://shipparts.com/vocab#Bow"})," and ",u("code",{children:"https://wrappingsupplies.com/vocab#Bow"}),"."]}),u("div",{children:"In most cases, it makes sense for your base URI to be the root or a subdirectory of your website. In all cases, the URI you choose should be in a domain that you control."}),u("div",{children:"For new Concepts and Concept Schemes, the Base URI field is pre-populated based on the most recently used Base URI value."})]}),components:{input:function(t){const n=e(["conceptId"]),r=e(["schemeId"]);return h(D,{space:2,children:[t.renderDefault(t),u(L,{muted:!0,size:1,onResize:void 0,onResizeCapture:void 0,children:h(f,{children:[u("strong",{children:"RDF URI: "}),t.value?t.value:"[base URI not defined] ",n||r||" [identifier not assigned]"]})})]})}}})];function so(e,t=[]){return s({name:"skosConcept",title:"Concept",type:"document",icon:x,initialValue:async(t,n)=>{if(e)return{baseIri:e,broader:[],related:[]};const{getClient:r}=n;return{baseIri:await r({apiVersion:"2021-03-25"}).fetch("\n *[(_type == 'skosConcept' || _type == 'skosConceptScheme') && defined(baseIri)]| order(_createdAt desc)[0].baseIri\n ")??void 0,broader:[],related:[]}},fields:[a({name:"prefLabel",title:"Preferred Label",type:"string",description:"The preferred lexical label for this concept.",validation:e=>e.required().custom(((e,t)=>{const{getClient:n}=t;return n({apiVersion:"2025-06-10"}).fetch(`*[_type == "skosConcept" && prefLabel == "${e}" && !(_id in path("drafts.**") || _id in path("versions.**"))][0]._id`).then((e=>!e||e===t.document?._id.replace("drafts.","")||"Preferred Label must be unique."))}))}),a({name:"definition",title:"Definition",type:"text",description:h(Yn,{children:[u("summary",{children:"A complete explanation of the intended meaning of the concept."}),h("div",{children:[h("kbd",{children:["Example: documentation",u("br",{}),'Definition: "The process of storing and retrieving information in all fields of knowledge."']}),h("p",{children:["For more information on the recommended usage of the SKOS documentation properties, see",h("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}),a({name:"example",title:"Examples",type:"text",description:h(Yn,{children:[u("summary",{children:"An example of the use of the concept."}),h("div",{children:[h("kbd",{children:["Example: organizations of science and culture",u("br",{}),'Example: "academies of science, general museums, world fairs"']}),h("p",{children:["For more information on the recommended usage of the SKOS documentation properties, see",h("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}),a({name:"scopeNote",title:"Scope Note",type:"text",description:h(Yn,{children:[u("summary",{children:"A brief statement on the intended meaning of this concept, especially as an indication of how the use of the concept is limited in indexing practice."}),h("div",{children:[h("kbd",{children:["Example: microwave frequencies",u("br",{}),'Scope Note: "Used for frequencies between 1Ghz and 300Ghz"']}),h("p",{children:["For more information on the recommended usage of the SKOS documentation properties, see",h("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}),a({name:"altLabel",title:"Alternate Label(s)",type:"array",description:h(Yn,{children:[u("summary",{children:"Synonyms, near-synonyms, abbreviations, and acronyms to a concept."}),u("div",{children:h("p",{children:[u(k,{})," Preferred, alternative, and hidden label sets must not overlap."]})})]}),of:[{type:"string"}],validation:e=>e.unique()}),a({name:"hiddenLabel",title:"Hidden Label(s)",type:"array",description:h(Yn,{children:[u("summary",{children:"Character strings that need to be accessible to applications performing text-based indexing and search operations, but which should not be displayed to end users."}),h("div",{children:[u("p",{children:"Hidden labels may for instance be used to include misspelled variants of other lexical labels."}),h("p",{children:[u(k,{})," Preferred, alternative, and hidden label sets must not overlap."]})]})]}),of:[{type:"string"}],validation:e=>e.unique()}),...ao,a({name:"conceptId",title:"Identifier",description:"This concept does not yet have a unique identifier.",type:"string",initialValue:()=>`${I(6)}`,hidden:({document:e})=>!!e?.conceptId,readOnly:({document:e})=>!!e?.conceptId,components:{input:sr}}),a({name:"broader",title:"Broader Concept(s)",description:h(Yn,{children:[u("summary",{children:"Create hierarchy between concepts, for example to create category/subcategory, part/whole, or class/instance relationships."}),u("div",{children:u("p",{children:"Broader and Associated relationships are mutually exclusive."})})]}),type:"array",of:[{type:"reference",to:{type:"skosConcept"},options:{filter:({document:e})=>({filter:'!(_id in $broader || _id in $related || _id in path("drafts.**") || _id == $self)',params:{self:e._id.replace("drafts.",""),broader:e.broader.map((({_ref:e})=>e)),related:e.related.map((({_ref:e})=>e))}})}}]}),a({name:"related",title:"Related Concept(s)",description:h(Yn,{children:[u("summary",{children:'Indicate that two concepts are inherently "related", but that one is not in any way more general than the other.'}),u("div",{children:u("p",{children:"Broader and Associated relationships are mutually exclusive."})})]}),type:"array",of:[{type:"reference",to:[{type:"skosConcept"}]}]}),...t,a({name:"historyNote",title:"History Notes",type:"text",description:h(Yn,{children:[u("summary",{children:"Significant changes to the meaning or the form of this concept."}),h("div",{children:[h("kbd",{children:["Example: person with disabilities",u("br",{}),'History Note: "Estab. 1992; heading was: handicapped [1884 - 1992]."']}),h("p",{children:["For more information on the recommended usage of the SKOS documentation properties, see",h("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}),a({name:"editorialNote",title:"Editorial Notes",type:"text",description:h(Yn,{children:[u("summary",{children:"Information to aid in administrative housekeeping, such as reminders of editorial work still to be done, or warnings in the event that future editorial changes might be made."}),h("div",{children:[h("kbd",{children:["Example: doubleclick",u("br",{}),'Editorial Note: "Review this term after the company merger is complete."']}),h("p",{children:["For more information on the recommended usage of the SKOS documentation properties, see",h("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}),a({name:"changeNote",title:"Change Notes",type:"text",description:h(Yn,{children:[u("summary",{children:"Fine-grained changes to a concept, for the purposes of administration and maintenance."}),h("div",{children:[h("kbd",{children:["Example: tomato",u("br",{}),"Change Note: \"Moved from under 'fruits' to under 'vegetables' by Horace Gray\""]}),h("p",{children:["For more information on the recommended usage of the SKOS documentation properties, see",h("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:N})}})}function co(){return u("svg",{"data-sanity-icon":!0,width:"25",height:"25",viewBox:"0 0 25 25",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:u("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"})})}function lo(e,t=[]){return s({name:"skosConceptScheme",title:"Concept Scheme",type:"document",icon:co,initialValue:async(t,n)=>{if(e)return{baseIri:e};const{getClient:r}=n;return{baseIri:await r({apiVersion:"2021-03-25"}).fetch("\n *[(_type == 'skosConcept' || _type == 'skosConceptScheme') && defined(baseIri)]| order(_createdAt desc)[0].baseIri\n ")??void 0}},fields:[a({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"}),a({name:"description",title:"Description",type:"text",rows:5,description:"Describe the intended use of this scheme."}),a({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:io}}),...ao,a({name:"schemeId",title:"Identifier",description:"This scheme does not yet have a unique identifier.",type:"string",initialValue:()=>`${I(6)}`,hidden:({document:e})=>!!e?.schemeId,readOnly:({document:e})=>!!e?.schemeId,components:{input:sr}}),a({name:"topConcepts",title:"Top Concepts",type:"array",validation:e=>e.unique(),of:[c({type:"reference",to:[{type:"skosConcept"}]})],options:{sortable:!1}}),a({name:"concepts",title:"Concepts",type:"array",validation:e=>e.unique(),of:[c({type:"reference",to:[{type:"skosConcept"}]})],options:{sortable:!1}}),...t],preview:{select:{title:"title"},prepare:({title:e})=>({title:e,media:co})}})}const po=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 e=>{const n=e?.getClient({apiVersion:"2023-01-01"});if(!n)throw new Error("Client not available");const{concepts:r,topConcepts:o}=await n.fetch(`{\n "concepts": *[_type=="skosConceptScheme" && schemeId == "${t}"].concepts[]._ref,\n "topConcepts": *[_type=="skosConceptScheme" && schemeId == "${t}"].topConcepts[]._ref\n }`);return{filter:'!(_id in path("drafts.**"))\n && (_id in $concepts\n || _id in $topConcepts)',params:{concepts:r,topConcepts:o,schemeId:t}}}},ho=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 e=>{const r=e?.getClient({apiVersion:"2023-01-01"});if(!r)throw new Error("Client not available");const{concepts:o}=await r.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 path("drafts.**")) && _id in $concepts',params:{concepts:o,schemeId:t,branchId:n}}}},uo=e=>e.list().title("Taxonomy Manager").items([e.documentTypeListItem("skosConceptScheme").title("Concept Schemes"),e.documentTypeListItem("skosConcept").title("Concepts")]),fo=(e,{schemaType:t})=>{switch(t){case"skosConceptScheme":return e.document().views([e.view.component(no).title("Tree View").icon(co),e.view.form().icon(S)]);case"skosConcept":return e.document().views([e.view.form().icon(S)]);default:e.view.form()}},mo=l((e=>{const{baseUri:t,customConceptFields:n,customSchemeFields:r}=e||{};return{name:"taxonomyManager",options:e,schema:{types:[so(t,n),lo(t,r)]},plugins:[p({name:"taxonomy",title:"Taxonomy",structure:uo,defaultDocumentNode:fo,icon:co})]}}));export{oo as ArrayHierarchyInput,ro as ReferenceHierarchyInput,no as TreeView,ho as branchFilter,po as schemeFilter,mo as taxonomyManager};//# sourceMappingURL=index.esm.esm.js.map
|
|
141
|
+
`,ar=Zn.p``;const sr=e=>{const{onChange:n}=e,r=j(),o=A((()=>{n(t(I(6))),r.push({status:"success",title:"Identifier created.",closable:!0})}),[n,r]);return u(D,{space:2,children:u(F,{space:[3,3,4],children:u(U,{tone:"primary",fontSize:2,onClick:o,text:"Generate Identifier"})})})};var cr=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},lr={},dr={},pr={};Object.defineProperty(pr,"__esModule",{value:!0});var hr="image-Tb9Ew8CXIwaY6R1kjMvI0uRR-2000x3000-jpg";pr.default=function(e){var t=e.split("-"),n=t[1],r=t[2],o=t[3];if(!n||!r||!o)throw new Error("Malformed asset _ref '".concat(e,"'. Expected an id like \"").concat(hr,'".'));var i=r.split("x"),a=+i[0],s=+i[1];if(!(isFinite(a)&&isFinite(s)))throw new Error("Malformed asset _ref '".concat(e,"'. Expected an id like \"").concat(hr,'".'));return{id:n,width:a,height:s,format:o}};var ur={},fr=cr&&cr.__assign||function(){return fr=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},fr.apply(this,arguments)};Object.defineProperty(ur,"__esModule",{value:!0});function mr(e){var t=e.split("/").slice(-1);return"image-".concat(t[0]).replace(/\.([a-z]+)$/,"-$1")}ur.default=function(e){if(!e)return null;var t,n;if("string"==typeof e&&/^https?:\/\//.test("".concat(e)))t={asset:{_ref:mr(e)}};else if("string"==typeof e)t={asset:{_ref:e}};else if((n=e)&&"string"==typeof n._ref)t={asset:e};else if(function(e){return!!e&&"string"==typeof e._id}(e))t={asset:{_ref:e._id||""}};else if(function(e){var t=e;return!(!t||!t.asset)&&"string"==typeof t.asset.url}(e))t={asset:{_ref:mr(e.asset.url)}};else{if("object"!=typeof e.asset)return null;t=fr({},e)}var r=e;return r.crop&&(t.crop=r.crop),r.hotspot&&(t.hotspot=r.hotspot),function(e){if(e.crop&&e.hotspot)return e;var t=fr({},e);return t.crop||(t.crop={left:0,top:0,bottom:0,right:0}),t.hotspot||(t.hotspot={x:.5,y:.5,height:1,width:1}),t}(t)},function(e){var t=cr&&cr.__assign||function(){return t=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},t.apply(this,arguments)},n=cr&&cr.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(e,"__esModule",{value:!0}),e.parseSource=e.SPEC_NAME_TO_URL_NAME_MAPPINGS=void 0;var r=n(pr),o=n(ur);e.parseSource=o.default,e.SPEC_NAME_TO_URL_NAME_MAPPINGS=[["width","w"],["height","h"],["format","fm"],["download","dl"],["blur","blur"],["sharpen","sharp"],["invert","invert"],["orientation","or"],["minHeight","min-h"],["maxHeight","max-h"],["minWidth","min-w"],["maxWidth","max-w"],["quality","q"],["fit","fit"],["crop","crop"],["saturation","sat"],["auto","auto"],["dpr","dpr"],["pad","pad"]],e.default=function(n){var i=t({},n||{}),a=i.source;delete i.source;var s=(0,o.default)(a);if(!s)throw new Error("Unable to resolve image URL from source (".concat(JSON.stringify(a),")"));var c=s.asset._ref||s.asset._id||"",l=(0,r.default)(c),d=Math.round(s.crop.left*l.width),p=Math.round(s.crop.top*l.height),h={left:d,top:p,width:Math.round(l.width-s.crop.right*l.width-d),height:Math.round(l.height-s.crop.bottom*l.height-p)},u=s.hotspot.height*l.height/2,f=s.hotspot.width*l.width/2,m=s.hotspot.x*l.width,g=s.hotspot.y*l.height,y={left:m-f,top:g-u,right:m+f,bottom:g+u};return i.rect||i.focalPoint||i.ignoreImageParams||i.crop||(i=t(t({},i),function(e,t){var n,r=t.width,o=t.height;if(!r||!o)return{width:r,height:o,rect:e.crop};var i=e.crop,a=e.hotspot,s=r/o,c=i.width/i.height;if(c>s){var l=Math.round(i.height),d=Math.round(l*s),p=Math.max(0,Math.round(i.top)),h=Math.round((a.right-a.left)/2+a.left);(u=Math.max(0,Math.round(h-d/2)))<i.left?u=i.left:u+d>i.left+i.width&&(u=i.left+i.width-d),n={left:u,top:p,width:d,height:l}}else{d=i.width,l=Math.round(d/s);var u=Math.max(0,Math.round(i.left)),f=Math.round((a.bottom-a.top)/2+a.top),m=Math.max(0,Math.round(f-l/2));m<i.top?m=i.top:m+l>i.top+i.height&&(m=i.top+i.height-l),n={left:u,top:m,width:d,height:l}}return{width:r,height:o,rect:n}}({crop:h,hotspot:y},i))),function(t){var n=(t.baseUrl||"https://cdn.sanity.io").replace(/\/+$/,""),r="".concat(t.asset.id,"-").concat(t.asset.width,"x").concat(t.asset.height,".").concat(t.asset.format),o="".concat(n,"/images/").concat(t.projectId,"/").concat(t.dataset,"/").concat(r),i=[];if(t.rect){var a=t.rect,s=a.left,c=a.top,l=a.width,d=a.height;(0!==s||0!==c||d!==t.asset.height||l!==t.asset.width)&&i.push("rect=".concat(s,",").concat(c,",").concat(l,",").concat(d))}t.bg&&i.push("bg=".concat(t.bg)),t.focalPoint&&(i.push("fp-x=".concat(t.focalPoint.x)),i.push("fp-y=".concat(t.focalPoint.y)));var p=[t.flipHorizontal&&"h",t.flipVertical&&"v"].filter(Boolean).join("");return p&&i.push("flip=".concat(p)),e.SPEC_NAME_TO_URL_NAME_MAPPINGS.forEach((function(e){var n=e[0],r=e[1];typeof t[n]<"u"?i.push("".concat(r,"=").concat(encodeURIComponent(t[n]))):typeof t[r]<"u"&&i.push("".concat(r,"=").concat(encodeURIComponent(t[r])))})),0===i.length?o:"".concat(o,"?").concat(i.join("&"))}(t(t({},i),{asset:l}))}}(dr);var gr=cr&&cr.__assign||function(){return gr=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},gr.apply(this,arguments)},yr=cr&&cr.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n),Object.defineProperty(e,r,{enumerable:!0,get:function(){return t[n]}})}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),br=cr&&cr.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),vr=cr&&cr.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)"default"!==n&&Object.prototype.hasOwnProperty.call(e,n)&&yr(t,e,n);return br(t,e),t};Object.defineProperty(lr,"__esModule",{value:!0}),lr.ImageUrlBuilder=void 0;var wr=vr(dr),Cr=["clip","crop","fill","fillmax","max","scale","min"],_r=["top","bottom","left","right","center","focalpoint","entropy"],Sr=["format"];function kr(e){for(var t=0,n=wr.SPEC_NAME_TO_URL_NAME_MAPPINGS;t<n.length;t++){var r=n[t],o=r[0],i=r[1];if(e===o||e===i)return o}return e}lr.default=function(e){if(function(e){return!(!e||!("config"in e))&&"function"==typeof e.config}(e)){var t=e.config(),n=t.apiHost,r=t.projectId,o=t.dataset;return new Ir(null,{baseUrl:(n||"https://api.sanity.io").replace(/^https:\/\/api\./,"https://cdn."),projectId:r,dataset:o})}var i=e;if(function(e){return!(!e||!("clientConfig"in e))&&"object"==typeof e.clientConfig}(i)){var a=i.clientConfig;n=a.apiHost,r=a.projectId,o=a.dataset;return new Ir(null,{baseUrl:(n||"https://api.sanity.io").replace(/^https:\/\/api\./,"https://cdn."),projectId:r,dataset:o})}return new Ir(null,e)};var Ir=function(){function e(e,t){this.options=gr(e?gr({},e.options||{}):{},t||{})}return e.prototype.withOptions=function(t){var n=t.baseUrl||this.options.baseUrl,r={baseUrl:n};for(var o in t)if(t.hasOwnProperty(o)){r[kr(o)]=t[o]}return new e(this,gr({baseUrl:n},r))},e.prototype.image=function(e){return this.withOptions({source:e})},e.prototype.dataset=function(e){return this.withOptions({dataset:e})},e.prototype.projectId=function(e){return this.withOptions({projectId:e})},e.prototype.bg=function(e){return this.withOptions({bg:e})},e.prototype.dpr=function(e){return this.withOptions(e&&1!==e?{dpr:e}:{})},e.prototype.width=function(e){return this.withOptions({width:e})},e.prototype.height=function(e){return this.withOptions({height:e})},e.prototype.focalPoint=function(e,t){return this.withOptions({focalPoint:{x:e,y:t}})},e.prototype.maxWidth=function(e){return this.withOptions({maxWidth:e})},e.prototype.minWidth=function(e){return this.withOptions({minWidth:e})},e.prototype.maxHeight=function(e){return this.withOptions({maxHeight:e})},e.prototype.minHeight=function(e){return this.withOptions({minHeight:e})},e.prototype.size=function(e,t){return this.withOptions({width:e,height:t})},e.prototype.blur=function(e){return this.withOptions({blur:e})},e.prototype.sharpen=function(e){return this.withOptions({sharpen:e})},e.prototype.rect=function(e,t,n,r){return this.withOptions({rect:{left:e,top:t,width:n,height:r}})},e.prototype.format=function(e){return this.withOptions({format:e})},e.prototype.invert=function(e){return this.withOptions({invert:e})},e.prototype.orientation=function(e){return this.withOptions({orientation:e})},e.prototype.quality=function(e){return this.withOptions({quality:e})},e.prototype.forceDownload=function(e){return this.withOptions({download:e})},e.prototype.flipHorizontal=function(){return this.withOptions({flipHorizontal:!0})},e.prototype.flipVertical=function(){return this.withOptions({flipVertical:!0})},e.prototype.ignoreImageParams=function(){return this.withOptions({ignoreImageParams:!0})},e.prototype.fit=function(e){if(-1===Cr.indexOf(e))throw new Error('Invalid fit mode "'.concat(e,'"'));return this.withOptions({fit:e})},e.prototype.crop=function(e){if(-1===_r.indexOf(e))throw new Error('Invalid crop mode "'.concat(e,'"'));return this.withOptions({crop:e})},e.prototype.saturation=function(e){return this.withOptions({saturation:e})},e.prototype.auto=function(e){if(-1===Sr.indexOf(e))throw new Error('Invalid auto mode "'.concat(e,'"'));return this.withOptions({auto:e})},e.prototype.pad=function(e){return this.withOptions({pad:e})},e.prototype.url=function(){return(0,wr.default)(this.options)},e.prototype.toString=function(){return this.url()},e}();lr.ImageUrlBuilder=Ir,(cr&&cr.__importDefault||function(e){return e&&e.__esModule?e:{default:e}})(lr);const xr={},Nr={apiVersion:"v2023-05-01"},Or=null;function Er(e){const t=M((()=>JSON.stringify(e||{})),[e]);return M((()=>JSON.parse(t)),[t])}function Pr(e,t){let{params:r=xr,options:o=Nr,initialValue:i=Or}=t;const[a,s]=V(!0),[c,l]=V(!1),[d,p]=V(i),h=Er(r),u=Er(o),f=E(null),m=n();return R((()=>{if(e&&!c&&!f.current)try{f.current=m.listenQuery(e,h,u).pipe(ne(te),re((e=>(console.error(e),l(e),s(!1),p(null),e)))).subscribe((e=>{p((t=>te(t,e)?t:e)),s(!1),l(!1)}))}catch(e){console.error(e),s(!1),l(e)}return c&&f.current&&f.current.unsubscribe(),()=>{var e;f.current&&(null==(e=f?.current)||e.unsubscribe(),f.current=null)}}),[e,c,h,u,m]),{data:d,loading:a,error:c}}var Tr,$r,Ar,Vr=Object.freeze,Rr=Object.defineProperty,Mr=(e,t)=>Vr(Rr(e,"raw",{value:Vr(e.slice())}));Zn((function(){return u(B,{as:"table",...arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}})}))((()=>Bn(Tr||(Tr=Mr(["\n display: table;\n width: 100%;\n border-collapse: collapse;\n\n &:not([hidden]) {\n display: table;\n border-collapse: collapse;\n }\n "])))));Zn((function(){return u(B,{as:"tr",...arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}})}))((()=>Bn($r||($r=Mr(["\n display: table-row;\n\n &:not([hidden]) {\n display: table-row;\n }\n "])))));Zn((function(){return u(B,{as:"td",...arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}})}))((()=>Bn(Ar||(Ar=Mr(["\n display: table-cell;\n\n &:not([hidden]) {\n display: table-cell;\n }\n "])))));const zr=(e=1)=>e>6?"":`"childConcepts": *[\n (\n (\n _id in $draftConceptIds &&\n !(conceptId in *[_id in $conceptIds].conceptId)\n ) \n ||\n (\n _id in $conceptIds &&\n !(conceptId in $draftConceptIds)\n )\n ) && ^._id in broader[]._ref ]|order(prefLabel){\n "id": _id,\n "level": ${e},\n prefLabel,\n definition,\n example,\n scopeNote,\n ${zr(e+1)}\n }`,Hr=(e=1)=>e>6?"":`"childConcepts": *[_id in *[_id == $id][0].concepts[]._ref && ^._id in broader[]._ref ]|order(prefLabel){\n "id": _id,\n "level": ${e},\n prefLabel,\n definition,\n example,\n scopeNote,\n ${Hr(e+1)}\n }`,Dr=z(null),Lr=z({editControls:!1});function jr(e){const t=j(),n=r({apiVersion:"2021-10-21"}),o=function(){const e=$(oe),{routerPanesState:t,groupIndex:n}=d();return A((r=>{if(!e||!r)return;const o=[...t];o.splice(n+1,n+1,[{id:r,params:{type:"skosConcept"}}]);const i=e.resolvePathFromState({panes:o});e.navigateUrl({path:i})}),[e,t,n])}(),i=e.displayed.baseIri;return A(((r,a,s)=>{let c;c=a?{_id:`drafts.${I()}`,_type:"skosConcept",conceptId:`${I(6)}`,prefLabel:"",baseIri:i,broader:[a&&{_key:I(6),_ref:a,_type:"reference"}],related:[]}:{_id:`drafts.${I()}`,_type:"skosConcept",conceptId:`${I(6)}`,prefLabel:"",baseIri:i,broader:[],related:[]};const l=JSON.parse(JSON.stringify(e.displayed));l._id.includes("drafts.")||(l._id=`drafts.${l._id}`),n.transaction().createIfNotExists(l).create(c).patch(l._id,(e=>"topConcept"==r?e.setIfMissing({topConcepts:[]}).append("topConcepts",[{_ref:c._id.replace("drafts.",""),_type:"reference",_key:I(6),_weak:!0,_strengthenOnPublish:{_type:"skosConcept",weak:!0,template:{id:"skosConcept",params:"undefined"}}}]):e.setIfMissing({concepts:[]}).insert("after","concepts[-1]",[{_ref:c._id.replace("drafts.",""),_type:"reference",_key:I(6),_weak:!0,_strengthenOnPublish:{_type:"skosConcept",weak:void 0,template:{id:"skosConcept",params:"undefined"}}}]))).commit({autoGenerateArrayKeys:!0}).then((e=>{t.push({closable:!0,status:"success",title:"Created new concept"}),o(c._id)})).catch((e=>{t.push({closable:!0,status:"error",title:"Error creating concept",description:e.message})}))}),[e.displayed,n,i,t,o])}function Fr(e){const t=j(),n=r({apiVersion:"2021-10-21"});return A(((r,o,i)=>{const a="topConcept"==o?"topConcepts":"concepts",s=JSON.parse(JSON.stringify(e.displayed));s._id.includes("drafts.")||(s._id=`drafts.${s._id}`),n.transaction().createIfNotExists(s).patch(s._id,(e=>e.unset([`${a}[_ref=="${r.replace("drafts.","")}"]`]))).commit().then((e=>{t.push({closable:!0,status:"success",title:(i?`"${i}"`:"Concept")+" removed from scheme"})})).catch((e=>{t.push({closable:!0,status:"error",title:"Error removing concept",description:e.message})}))}),[n,e.displayed,t])}function Ur(){return"dark"==o()?H.gray[50].hex:H.gray[800].hex}function Br({concept:e}){const t=$(oe),{routerPanesState:n,groupIndex:r}=d(),o=Ur(),{id:i,prefLabel:a}=e??{},s=A((()=>{if(!t||!i)return;const e=[...n];e.splice(r+1,r+1,[{id:i,params:{type:"skosConcept"}}]);const o=t.resolvePathFromState({panes:e});t.navigateUrl({path:o})}),[i,t,n,r]);return u(ir,{href:"#",onClick:s,style:{color:o},children:a})}const qr=({concept:e})=>{const[t,n]=V(!1),r=A((()=>n(!1)),[]),o=A((()=>n(!0)),[]),i=Ur();return e&&(e.definition||e.example||e.scopeNote)?h(f,{children:[u(Qn,{className:"action","aria-label":"info",onClick:o,type:"button",children:u(m,{className:"info",style:{color:i}})}),t&&u(q,{header:e.prefLabel,id:"dialog-example",onClose:r,zOffset:1e3,width:1,children:u(G,{padding:4,paddingBottom:5,children:h(D,{space:4,children:[e.definition&&h(D,{space:2,children:[u(Z,{size:1,children:"Definition"}),u(L,{size:2,muted:!0,style:{whiteSpace:"pre-wrap"},children:e.definition})]}),e.example&&h(D,{space:2,children:[u(Z,{size:1,children:"Example"}),u(L,{size:2,muted:!0,style:{whiteSpace:"pre-wrap"},children:e.example})]}),e.scopeNote&&h(D,{space:2,children:[u(Z,{size:1,children:"Scope Note"}),u(L,{size:2,muted:!0,style:{whiteSpace:"pre-wrap"},children:e.scopeNote})]})]})})})]}):null};function Gr({concept:e,selectConcept:t}){const{prefLabel:n,id:r}=e??{},o=Ur(),i=A((()=>{t({_ref:r,_type:"reference"})}),[r,t]);return u(f,{children:t?u(ir,{href:"#",onClick:i,style:{color:o},children:n}):u(ar,{children:n})})}const Zr=({concept:e,selectConcept:t,inputComponent:n=!1})=>{const r=$(Dr)||{},{globalVisibility:{treeVisibility:o}}=$(Lr)||{},{editControls:i}=$(Lr)||{editControls:!1},a=jr(r),s=Fr(r),c=A((()=>{a("concept",e?.id,e?.prefLabel)}),[e?.id,e?.prefLabel,a]),l=A((()=>{s(e.id,"concept",e?.prefLabel)}),[e.id,e?.prefLabel,s]),[d,p]=V(o),f=A((()=>{"open"==d?p("closed"):"closed"==d&&p("open")}),[d]);return h(or,{className:d,children:[h(F,{space:2,children:[h(F,{space:1,children:[h(F,{space:1,children:[e?.childConcepts&&e.childConcepts.length>0&&u(er,{onClick:f,type:"button","aria-expanded":"open"==d,children:u(g,{})}),e?.childConcepts&&0==e.childConcepts.length&&u(y,{className:"spacer"}),!e?.prefLabel&&u("span",{className:"untitled",children:"[new concept]"}),n?u(Gr,{concept:e,selectConcept:t}):u(Br,{concept:e})]}),!i&&u(qr,{concept:e})]}),i&&e?.level&&e.level<5&&h(F,{space:2,children:[u(Qn,{onClick:c,type:"button",className:"action","aria-label":"Add child a child concept",children:u(b,{className:"add"})}),u(Qn,{onClick:l,type:"button",className:"action","aria-label":"Remove concept from scheme",children:u(v,{className:"remove"})})]}),i&&0==e.childConcepts?.length&&5==e.level&&h(F,{space:2,children:[u(W,{content:u(G,{padding:2,sizing:"border",children:u(D,{padding:1,space:2,children:u(L,{muted:!0,size:1,children:"This concept is at the maximum Taxonomy Manager hierarchy depth of 5 levels."})})}),fallbackPlacements:["right","left"],placement:"top",children:u(m,{className:"info warning"})}),u(Qn,{onClick:l,type:"button",className:"action","aria-label":"Remove concept from scheme",children:u(v,{className:"remove"})})]}),e?.childConcepts&&e?.childConcepts?.length>0&&5==e.level&&h(F,{space:1,children:[u(W,{content:u(G,{padding:2,sizing:"border",children:h(D,{padding:1,space:2,children:[u(L,{muted:!0,size:1,children:"This concept has unlisted child concepts."}),u(L,{muted:!0,size:1,children:"The maximum hierarchy depth is 5 levels."})]})}),fallbackPlacements:["right","left"],placement:"top",children:u(w,{className:"info error"})}),r.displayed?.controls&&u(Qn,{onClick:l,type:"button",className:"action","aria-label":"Remove concept from scheme",children:u(v,{className:"remove"})})]})]}),e?.childConcepts&&e.childConcepts.length>0&&e?.level&&e.level<5&&u(Wr,{concepts:e.childConcepts,selectConcept:t,inputComponent:n})]})},Wr=({concepts:e,inputComponent:t=!1,selectConcept:n})=>u(rr,{children:e.map((e=>u(Zr,{concept:e,selectConcept:n,inputComponent:t},e.id)))}),Yr=({concept:e,treeVisibility:t,inputComponent:n,selectConcept:r})=>{const o=$(Dr)||{},{editControls:i}=$(Lr)||{editControls:!1},a=jr(o),s=Fr(o),[c,l]=V(t),d=A((()=>{"open"==c?l("closed"):"closed"==c&&l("open")}),[c]),p=A((()=>{a("concept",e?.id,e?.prefLabel)}),[e?.id,e?.prefLabel,a]),f=A((()=>{s(e?.id,"topConcept",e?.prefLabel)}),[e?.id,e?.prefLabel,s]);return h(tr,{className:c,children:[h(F,{space:2,children:[h(F,{space:0,children:[e?.childConcepts&&e.childConcepts.length>0&&u(er,{onClick:d,type:"button","aria-expanded":"open"==c,children:u(g,{})}),e?.childConcepts&&0==e.childConcepts.length&&u(y,{className:"spacer"}),!e?.prefLabel&&u("span",{className:"untitled",children:"[new concept]"}),n?u(Gr,{concept:e,selectConcept:r}):u(Br,{concept:e})]}),u(L,{size:1,muted:!0,children:"top concept"}),!i&&u(qr,{concept:e}),i&&h(F,{space:2,children:[u(W,{content:u(G,{padding:2,sizing:"border",children:u(D,{padding:1,space:2,children:u(L,{muted:!0,size:1,children:"Add a child concept"})})}),fallbackPlacements:["right","left"],placement:"top",children:u(Qn,{onClick:p,type:"button",className:"action","aria-label":"Add child a child concept",children:u(b,{className:"add"})})}),u(W,{content:u(G,{padding:2,sizing:"border",children:u(D,{padding:1,space:2,children:u(L,{muted:!0,size:1,children:"Remove concept from scheme"})})}),fallbackPlacements:["right","left"],placement:"top",children:u(Qn,{onClick:f,type:"button",className:"action","aria-label":"Remove concept from scheme",children:u(v,{className:"remove"})})})]})]}),e?.childConcepts&&e.childConcepts.length>0&&u(Wr,{concepts:e.childConcepts,selectConcept:r,inputComponent:n})]})},Kr=({concept:e,treeVisibility:t,inputComponent:n,selectConcept:r})=>{const o=$(Dr)||{},{editControls:i}=$(Lr)||{editControls:!1},a=jr(o),s=Fr(o),[c,l]=V(t),d=A((()=>{"open"==c?l("closed"):"closed"==c&&l("open")}),[c]),p=A((()=>{a("concept",e?.id,e?.prefLabel)}),[e?.id,e?.prefLabel,a]),f=A((()=>{s(e.id,"concept",e?.prefLabel)}),[e.id,e?.prefLabel,s]);return h(nr,{className:c,children:[h(F,{space:2,children:[e?.childConcepts&&e.childConcepts.length>0&&u(er,{onClick:d,type:"button","aria-expanded":"open"==c,children:u(g,{})}),e?.childConcepts&&0==e.childConcepts.length&&u(y,{className:"spacer"}),!e?.prefLabel&&u("span",{className:"untitled",children:"[new concept]"}),n?u(Gr,{concept:e,selectConcept:r}):u(Br,{concept:e}),o.displayed?.topConcepts?.length>0&&u(L,{size:1,muted:!0,children:"orphan"}),!i&&u(qr,{concept:e}),!n&&i&&h(F,{space:2,children:[u(W,{content:u(G,{padding:2,sizing:"border",children:u(D,{padding:1,space:2,children:u(L,{muted:!0,size:1,children:"Add a child concept"})})}),fallbackPlacements:["right","left"],placement:"top",children:u(Qn,{onClick:p,type:"button",className:"action","aria-label":"Add child a child concept",children:u(b,{className:"add"})})}),u(W,{content:u(G,{padding:2,sizing:"border",children:u(D,{padding:1,space:2,children:u(L,{muted:!0,size:1,children:"Remove concept from scheme"})})}),fallbackPlacements:["right","left"],placement:"top",children:u(Qn,{onClick:f,type:"button",className:"action","aria-label":"Remove concept from scheme",children:u(v,{className:"remove"})})})]})]}),e?.childConcepts&&e.childConcepts.length>0&&u(Wr,{concepts:e.childConcepts,selectConcept:r,inputComponent:n})]})},Xr=({document:e})=>{const[t,n]=V(!1),[o,i]=V(""),[a,s]=V(""),c=A((()=>n(!1)),[]),l=A((()=>n(!0)),[]),d=A((e=>{i(e.currentTarget.value)}),[]),p=A((e=>{s(e.currentTarget.value)}),[]),f=function(){const e=j(),t=r({apiVersion:"2021-10-21"});return A(((n,r,o)=>{const i=n.displayed?._id,a=n.displayed?.baseIri,s=n.displayed?.schemeId,c={_id:`drafts.${i}`,_type:"skosConceptScheme",schemeId:s,baseIri:a,title:r,description:o||""};t.createIfNotExists(c).then((t=>o?e.push({closable:!0,status:"success",title:"Title and Description added."}):e.push({closable:!0,status:"success",title:"Title added."}))).catch((t=>{e.push({closable:!0,status:"error",title:"There has been an error",description:t.message})}))}),[t,e])}(),m=A((()=>{f(e,o,a)}),[f,a,e,o]);return h(Kn,{children:[u(B,{padding:[3,3,4],radius:2,shadow:1,tone:"primary",children:h(D,{space:6,children:[h(D,{space:4,children:[u(Z,{size:4,children:"New Concept Scheme"}),u(L,{size:2,children:'To start using hierarchy view taxonomy builder, first give your concept scheme a name and optional description. You can also use the "Editor" tab to add concepts to the tree manually.'})]}),u(U,{tone:"primary",fontSize:2,icon:C,onClick:l,text:"Add Title"})]})}),t&&u(q,{header:"Title & Description",id:"title-description",onClose:c,zOffset:1e3,width:1,children:u(G,{padding:4,children:h(D,{space:4,children:[h(D,{space:2,children:[u(Z,{size:1,children:"Title"}),u(L,{size:1,muted:!0,children:"Describe the concept scheme in one or two words."})]}),u(Y,{fontSize:2,onChange:d,padding:3,placeholder:"",value:o}),h(D,{space:2,children:[u(Z,{size:1,children:"Description (optional)"}),u(L,{size:1,muted:!0,children:"Describe the intended use of this concept scheme."})]}),u(K,{fontSize:2,onChange:p,padding:3,placeholder:"",value:a,rows:3}),u(U,{tone:"primary",fontSize:2,onClick:m,text:"Save"})]})})})]})},Jr=()=>u(Kn,{children:u(B,{padding:[3,3,4],radius:2,shadow:1,tone:"primary",children:h(D,{space:4,children:[u(Z,{size:4,children:"No Concepts"}),u(L,{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 children to them. To create a flat list of concepts, create Entry Concepts directly."})]})})}),Qr=({concepts:e,inputComponent:t,selectConcept:n})=>{const{globalVisibility:{treeId:r,treeVisibility:o}={treeId:123,treeVisibility:"open"},setEditControls:i=()=>{console.warn("setEditControls not defined")}}=$(Lr)||{};return R((()=>{e?.topConcepts&&0===e.topConcepts.length&&e?.orphans&&0===e.orphans.length&&i(!0)}),[e.topConcepts,e.orphans,i]),e?.topConcepts&&0===e.topConcepts.length&&e?.orphans&&0===e.orphans.length?u(Jr,{}):h(Xn,{children:[e.topConcepts&&e.topConcepts.map((e=>u(Yr,{concept:e,treeVisibility:o,inputComponent:t,selectConcept:n},e?.id+r))),e.orphans.map((e=>u(Kr,{concept:e,treeVisibility:o,inputComponent:t,selectConcept:n},e.id+r)))]})},eo=({branchId:e="",selectConcept:t,inputComponent:n})=>{const r=$(Dr)||{},o=r.displayed?._id,{data:i,loading:a,error:s}=Pr({fetch:`\n select($branchId != null => \n *[_id == $id][0] {\n _updatedAt,\n "topConcepts":*[_type == "skosConcept" && conceptId == $branchId]{\n "id": _id,\n "level": 0,\n prefLabel,\n definition,\n example,\n scopeNote,\n ${Hr()}\n }, \n "orphans": []\n },\n *[_id == $id][0] {\n _updatedAt,\n "topConcepts":topConcepts[]->|order(prefLabel){\n "id": _id,\n "level": 0,\n prefLabel,\n definition,\n example,\n scopeNote,\n ${Hr()}\n }, \n "orphans": *[\n _id in coalesce(*[_id == 'drafts.' + $id][0], *[_id == $id][0]).concepts[]._ref &&\n count((broader[]._ref) [@ in coalesce(*[_id == 'drafts.' + $id][0], *[_id == $id][0]).topConcepts[]._ref]) < 1 &&\n count((broader[]._ref) [@ in coalesce(*[_id == 'drafts.' + $id][0], *[_id == $id][0]).concepts[]._ref]) < 1\n ]|order(prefLabel){\n "id": _id,\n "level": 0,\n prefLabel,\n definition,\n example,\n scopeNote,\n ${Hr()}\n }\n }\n )`,listen:'*[_type == "skosConcept" || _id == $id]'},{params:{id:o,branchId:e}});return a?u(G,{padding:5,children:h(X,{align:"center",direction:"column",gap:5,height:"fill",justify:"center",style:{paddingTop:"1rem"},children:[u(J,{muted:!0}),u(L,{muted:!0,size:1,children:"Loading hierarchy…"})]})}):s?(console.warn(s),u(G,{padding:4,children:u(B,{padding:[3],radius:2,shadow:1,tone:"caution",children:u(L,{size:1,children:"There was a problem loading terms. Please check the scheme configuration and try again."})})})):i?u(Lr.Provider,{value:{globalVisibility:{treeId:"123",treeVisibility:"open"}},children:u(G,{padding:4,children:u(Qr,{concepts:i,inputComponent:n,selectConcept:t})})}):u(Xr,{document:r})},to=({branchId:e="",selectConcept:t,inputComponent:n=!1})=>{const r=$(Dr)||{},o=r.displayed?._id,i=r.displayed?.concepts?.map((e=>e?._ref))||[],a=r.displayed?.concepts?.map((e=>`drafts.${e?._ref}`))||[],s=r.displayed?.topConcepts?.map((e=>e?._ref))||[],c=r.displayed?.topConcepts?.map((e=>`drafts.${e?._ref}`))||[],l=jr(r),d=A((()=>{l("topConcept")}),[l]),p=A((()=>{l("concept")}),[l]),[m,g]=V({treeId:I(3),treeVisibility:"open"}),[y,v]=V(!1);R((()=>{r.displayed._id.includes("drafts.")||v(!1)}),[r.displayed._id]);const w=A((()=>{g({treeId:I(3),treeVisibility:"open"})}),[]),C=A((()=>{g({treeId:I(3),treeVisibility:"closed"})}),[]),k=A((()=>{v(!0)}),[]),x=A((()=>{v(!1)}),[]),{data:N,loading:O,error:E}=Pr({fetch:`*[_id == $id][0] {\n _updatedAt,\n "topConcepts": *[\n (\n _id in $draftTopConceptIds &&\n !(conceptId in *[_id in $topConceptIds].conceptId)\n )\n ||\n (\n _id in $topConceptIds\n )\n ]|order(prefLabel) {\n "id": _id,\n "level": 0,\n prefLabel,\n definition,\n example,\n scopeNote,\n ${zr()}\n },\n "orphans": *[\n ((\n _id in $draftConceptIds &&\n !(conceptId in *[_id in $conceptIds].conceptId)\n )\n ||\n (\n _id in $conceptIds\n )) &&\n count(\n (broader[]._ref) [@ in coalesce(\n *[_id == 'drafts.' + $id][0], \n *[_id == $id][0]\n ).topConcepts[]._ref]) < 1 &&\n count(\n (broader[]._ref) [@ in coalesce(\n *[_id == 'drafts.' + $id][0], \n *[_id == $id][0]\n ).concepts[]._ref]) < 1\n ]|order(prefLabel){\n "id": _id,\n "level": 0,\n prefLabel,\n definition,\n example,\n scopeNote,\n ${zr()}\n }\n }`,listen:'*[_type == "skosConcept" || _id == $id ]'},{params:{id:o,branchId:e,conceptIds:i,draftConceptIds:a,topConceptIds:s,draftTopConceptIds:c}});return O?u(G,{padding:5,children:h(X,{align:"center",direction:"column",gap:5,height:"fill",justify:"center",style:{paddingTop:"1rem"},children:[u(J,{muted:!0}),u(L,{muted:!0,size:1,children:"Loading hierarchy…"})]})}):E?(console.error(E),u("div",{children:"Error here"})):N?u(Lr.Provider,{value:{globalVisibility:m,editControls:y,setEditControls:v},children:u(G,{padding:4,paddingTop:2,children:h(f,{children:[u(D,{space:4,children:u(B,{borderBottom:!0,paddingBottom:1,display:"flex",flex:1,children:h(X,{justify:"space-between",flex:1,children:[u(B,{children:(N.topConcepts?.filter((e=>(e?.childConcepts?.length??0)>0)).length>0||N.orphans?.filter((e=>(e?.childConcepts?.length??0)>0)).length>0)&&h(F,{space:1,children:[u(Jn,{type:"button",onClick:C,children:u(L,{weight:"semibold",muted:!0,size:1,children:"Collapse"})}),u(L,{weight:"semibold",muted:!0,size:1,children:"|"}),u(Jn,{type:"button",onClick:w,children:u(L,{weight:"semibold",muted:!0,size:1,children:"Expand"})})]})}),u(B,{children:y?h(F,{space:1,children:[u(Jn,{type:"button",className:"add",onClick:d,children:h(L,{weight:"semibold",muted:!0,size:1,children:[u(b,{})," Add Top Concept"]})}),u(Jn,{type:"button",className:"add",onClick:p,children:h(L,{weight:"semibold",muted:!0,size:1,children:[u(b,{})," Add Concept"]})}),u(Jn,{type:"button",onClick:x,children:h(L,{weight:"semibold",muted:!0,size:1,children:[u(_,{})," Done"]})})]}):u(F,{space:2,children:u(Jn,{type:"button",onClick:k,children:h(L,{weight:"semibold",muted:!0,size:1,children:[u(S,{})," Edit"]})})})})]})})}),u(Qr,{concepts:N,inputComponent:n,selectConcept:t})]})})}):u(Xr,{document:r})},no=({document:e,branchId:t,selectConcept:n,inputComponent:r=!1})=>u(Dr.Provider,{value:e,children:r?u(eo,{inputComponent:r,branchId:t,selectConcept:n}):h(Q,{width:1,style:{paddingTop:"1.25rem"},children:[e?.displayed?.description&&u(G,{padding:4,children:u(D,{space:4,children:h(D,{space:2,children:[u(L,{size:1,weight:"semibold",children:"Description"}),u(L,{size:2,muted:!0,style:{whiteSpace:"pre-wrap"},children:e?.displayed.description})]})})}),u(to,{inputComponent:r,branchId:t})]})});function ro(t){const{name:n,title:o}=t,i=e(["_id"]),a=r({apiVersion:"2021-10-21"}),[s,c]=V(!0),[l,d]=V(!0),[p,f]=V(!1),[m,g]=V({}),[y,b]=V(null),{schemeId:v,branchId:w=null}=y?.params||{},{filter:C}=t.schemaType.options;R((()=>{!async function(){try{const e=await C({getClient:()=>a});b(e),d(!1)}catch(e){console.error("Error fetching filter values: ",e)}}()}),[C,a]),R((()=>{a.fetch(`{"displayed": *[schemeId == "${v}"][0]}`).then((e=>{e?.displayed&&(g(e),c(!1))})).catch((e=>console.warn(e)))}),[a,v]);const _=A((()=>{f(!0)}),[]),S=A((()=>{f(!1)}),[]),k=A((e=>{i.includes("drafts.")?a.patch(i).set({[n]:e}).commit().then((()=>f(!1))).catch((e=>console.error(e))):a.fetch(`*[_id == "${i}"][0]`).then((t=>{t._id=`drafts.${t._id}`,t[n]=e,a.create(t)})).then((()=>f(!1))).catch((e=>console.error(e)))}),[a,i,n]);return t.schemaType.options?.filter?0==t.schemaType.options.filter.length?h(D,{space:3,children:[t.renderDefault(t),u(G,{padding:4,children:u(B,{padding:[3],radius:2,shadow:1,tone:"caution",children:h(L,{size:1,children:["There was a problem loading your filter settings. Please check the"," ",u("code",{children:"schemeFilter()"})," or ",u("code",{children:"branchFilter()"})," configuration for the"," ",o," field."]})})})]}):s||l?u(G,{padding:5,children:h(X,{align:"center",direction:"column",gap:5,height:"fill",justify:"center",style:{paddingTop:"1rem"},children:[u(J,{muted:!0}),u(L,{muted:!0,size:1,children:"Loading input component…"})]})}):h(D,{space:3,children:[t.renderDefault(t),u(ee,{columns:1,gap:3,children:u(U,{text:"Browse Taxonomy Tree",mode:"ghost",onClick:_})}),p&&u(q,{header:o,id:"concept-select-dialog",onClose:S,zOffset:900,width:1,children:u(G,{padding:10,children:u(no,{document:m,branchId:w,inputComponent:!0,selectConcept:k})})})]}):h(D,{space:3,children:[t.renderDefault(t),u(G,{padding:4,children:u(B,{padding:[3],radius:2,shadow:1,tone:"caution",children:h(L,{size:1,children:["The ",u("code",{children:"ReferenceHierarchyInput()"})," component must be used with an accompanying"," ",u("code",{children:"schemeFilter()"})," or ",u("code",{children:"branchFilter()"}),". Please add an appropriate filter to the configuration for the ",o," field."]})})})]})}function oo(t){const{name:n,title:o,value:i=[]}=t,a=e(["_id"]),s=r({apiVersion:"2021-10-21"}),[c,l]=V(!0),[d,p]=V(!0),[f,m]=V(!1),[g,y]=V({}),[b,v]=V(null),{schemeId:w,branchId:C=null}=b?.params||{},{filter:_}=t.schemaType.of[0].options,S=j();R((()=>{!async function(){try{const e=await _({getClient:()=>s});v(e),p(!1)}catch(e){console.error("Error fetching filter values: ",e)}}()}),[_,s]),R((()=>{s.fetch(`{"displayed": *[schemeId == "${w}"][0]}`).then((e=>{e?.displayed&&(y(e),l(!1))})).catch((e=>console.warn(e)))}),[s,w]);const k=A((()=>{m(!0)}),[]),I=A((()=>{m(!1)}),[]),x=A((e=>{if(i&&i.map((e=>e._ref)).includes(e._ref))return m(!1),void S.push({status:"warning",title:"Taxonomy Term Not Added",description:"The selected concept is already included in this field.",duration:5e3,closable:!0});a.includes("drafts.")?s.patch(a).setIfMissing({[n]:[]}).append(n,[e]).commit({autoGenerateArrayKeys:!0}).then((()=>m(!1))).catch((e=>console.error(e))):s.fetch(`*[_id == "${a}"][0]`).then((e=>{e._id=`drafts.${e._id}`,s.create(e)})).then((()=>{s.patch(`drafts.${a}`).setIfMissing({[n]:[]}).append(n,[e]).commit({autoGenerateArrayKeys:!0}).then((()=>m(!1))).catch((e=>console.error(e)))})).catch((e=>console.error(e)))}),[s,a,n,i,S]);return t.schemaType.of[0].options?.filter?0==t.schemaType.of[0].options.filter.length?h(D,{space:3,children:[t.renderDefault(t),u(G,{padding:4,children:u(B,{padding:[3],radius:2,shadow:1,tone:"caution",children:h(L,{size:1,children:["There was a problem loading your filter settings. Please check the"," ",u("code",{children:"schemeFilter()"})," or ",u("code",{children:"branchFilter()"})," configuration for the"," ",o," field."]})})})]}):t.schemaType.of.length>1?h(D,{space:3,children:[t.renderDefault(t),u(B,{padding:[3],radius:2,shadow:1,tone:"caution",children:u(D,{space:4,children:h(D,{space:2,children:[u(Z,{size:2,children:"Input Component Not Supported for Multi-Schema Arrays"}),h(L,{size:1,children:["The Sanity Taxonomy Manager Hierarchy Input Component is not designed to support array inputs with more than one schema type. Please see the"," ",u("a",{href:"https://sanitytaxonomymanager.com",children:"Taxonomy Manager docs"})," for more information."]})]})})})]}):c||d?u(G,{padding:5,children:h(X,{align:"center",direction:"column",gap:5,height:"fill",justify:"center",style:{paddingTop:"1rem"},children:[u(J,{muted:!0}),u(L,{muted:!0,size:1,children:"Loading input component…"})]})}):h(D,{space:3,children:[t.renderDefault(t),u(ee,{columns:1,gap:3,children:u(U,{text:"Browse Taxonomy Tree",mode:"ghost",onClick:k})}),f&&u(q,{header:o,id:"concept-select-dialog",onClose:I,zOffset:900,width:1,children:u(G,{padding:10,children:u(no,{document:g,branchId:C,inputComponent:!0,selectConcept:x})})})]}):h(D,{space:3,children:[t.renderDefault(t),u(G,{padding:4,children:u(B,{padding:[3],radius:2,shadow:1,tone:"caution",children:h(L,{size:1,children:["The ",u("code",{children:"ArrayHierarchyInput()"})," component must be used with an accompanying"," ",u("code",{children:"schemeFilter()"})," or ",u("code",{children:"branchFilter()"}),". Please add an appropriate filter to the configuration for the ",o," field."]})})})]})}const io=e=>{const{onChange:t}=e,n=j(),r=A((()=>{t(i()),n.push({status:"success",title:"Value removed.",duration:2500,closable:!0})}),[t,n]);return u(D,{space:2,children:h(F,{space:[3,3,4],children:[e.renderDefault(e),u(U,{tone:"primary",fontSize:2,onClick:r,text:"Remove Value"})]})})};var ao=[a({name:"baseIri",title:"Base URI",type:"url",validation:e=>e.required().error("Please supply a base URI in the format 'http://example.com/'"),description:h(Yn,{children:[u("summary",{children:"The root URI (Uniform Resource Identifier) used to create unique concept identifiers."}),h("div",{children:["Unique identifiers allow for the clear an unambiguous identification of concepts across namespaces, for example between ",u("code",{children:"https://shipparts.com/vocab#Bow"})," and ",u("code",{children:"https://wrappingsupplies.com/vocab#Bow"}),"."]}),u("div",{children:"In most cases, it makes sense for your base URI to be the root or a subdirectory of your website. In all cases, the URI you choose should be in a domain that you control."}),u("div",{children:"For new Concepts and Concept Schemes, the Base URI field is pre-populated based on the most recently used Base URI value."})]}),components:{input:function(t){const n=e(["conceptId"]),r=e(["schemeId"]);return h(D,{space:2,children:[t.renderDefault(t),u(L,{muted:!0,size:1,onResize:void 0,onResizeCapture:void 0,children:h(f,{children:[u("strong",{children:"RDF URI: "}),t.value?t.value:"[base URI not defined] ",n||r||" [identifier not assigned]"]})})]})}}})];function so(e,t=[]){return s({name:"skosConcept",title:"Concept",type:"document",icon:x,initialValue:async(t,n)=>{if(e)return{baseIri:e,broader:[],related:[]};const{getClient:r}=n;return{baseIri:await r({apiVersion:"2021-03-25"}).fetch("\n *[(_type == 'skosConcept' || _type == 'skosConceptScheme') && defined(baseIri)]| order(_createdAt desc)[0].baseIri\n ")??void 0,broader:[],related:[]}},fields:[a({name:"prefLabel",title:"Preferred Label",type:"string",description:"The preferred lexical label for this concept.",validation:e=>e.required().custom(((e,t)=>{const{getClient:n}=t;return n({apiVersion:"2025-06-10"}).withConfig({perspective:"raw"}).fetch(`*[_type == "skosConcept" && prefLabel == "${e}" && !(_id in path("drafts.**") || _id in path("versions.**"))][0]._id`).then((e=>!(e&&!t.document?._id.includes(e))||"Preferred Label must be unique."))}))}),a({name:"definition",title:"Definition",type:"text",description:h(Yn,{children:[u("summary",{children:"A complete explanation of the intended meaning of the concept."}),h("div",{children:[h("kbd",{children:["Example: documentation",u("br",{}),'Definition: "The process of storing and retrieving information in all fields of knowledge."']}),h("p",{children:["For more information on the recommended usage of the SKOS documentation properties, see",h("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}),a({name:"example",title:"Examples",type:"text",description:h(Yn,{children:[u("summary",{children:"An example of the use of the concept."}),h("div",{children:[h("kbd",{children:["Example: organizations of science and culture",u("br",{}),'Example: "academies of science, general museums, world fairs"']}),h("p",{children:["For more information on the recommended usage of the SKOS documentation properties, see",h("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}),a({name:"scopeNote",title:"Scope Note",type:"text",description:h(Yn,{children:[u("summary",{children:"A brief statement on the intended meaning of this concept, especially as an indication of how the use of the concept is limited in indexing practice."}),h("div",{children:[h("kbd",{children:["Example: microwave frequencies",u("br",{}),'Scope Note: "Used for frequencies between 1Ghz and 300Ghz"']}),h("p",{children:["For more information on the recommended usage of the SKOS documentation properties, see",h("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}),a({name:"altLabel",title:"Alternate Label(s)",type:"array",description:h(Yn,{children:[u("summary",{children:"Synonyms, near-synonyms, abbreviations, and acronyms to a concept."}),u("div",{children:h("p",{children:[u(k,{})," Preferred, alternative, and hidden label sets must not overlap."]})})]}),of:[{type:"string"}],validation:e=>e.unique()}),a({name:"hiddenLabel",title:"Hidden Label(s)",type:"array",description:h(Yn,{children:[u("summary",{children:"Character strings that need to be accessible to applications performing text-based indexing and search operations, but which should not be displayed to end users."}),h("div",{children:[u("p",{children:"Hidden labels may for instance be used to include misspelled variants of other lexical labels."}),h("p",{children:[u(k,{})," Preferred, alternative, and hidden label sets must not overlap."]})]})]}),of:[{type:"string"}],validation:e=>e.unique()}),...ao,a({name:"conceptId",title:"Identifier",description:"This concept does not yet have a unique identifier.",type:"string",initialValue:()=>`${I(6)}`,hidden:({document:e})=>!!e?.conceptId,readOnly:({document:e})=>!!e?.conceptId,components:{input:sr}}),a({name:"broader",title:"Broader Concept(s)",description:h(Yn,{children:[u("summary",{children:"Create hierarchy between concepts, for example to create category/subcategory, part/whole, or class/instance relationships."}),u("div",{children:u("p",{children:"Broader and Associated relationships are mutually exclusive."})})]}),type:"array",of:[{type:"reference",to:{type:"skosConcept"},options:{filter:({document:e})=>({filter:'!(_id in $broader || _id in $related || _id in path("drafts.**") || _id == $self)',params:{self:e._id.replace("drafts.",""),broader:e.broader.map((({_ref:e})=>e)),related:e.related.map((({_ref:e})=>e))}})}}]}),a({name:"related",title:"Related Concept(s)",description:h(Yn,{children:[u("summary",{children:'Indicate that two concepts are inherently "related", but that one is not in any way more general than the other.'}),u("div",{children:u("p",{children:"Broader and Associated relationships are mutually exclusive."})})]}),type:"array",of:[{type:"reference",to:[{type:"skosConcept"}]}]}),...t,a({name:"historyNote",title:"History Notes",type:"text",description:h(Yn,{children:[u("summary",{children:"Significant changes to the meaning or the form of this concept."}),h("div",{children:[h("kbd",{children:["Example: person with disabilities",u("br",{}),'History Note: "Estab. 1992; heading was: handicapped [1884 - 1992]."']}),h("p",{children:["For more information on the recommended usage of the SKOS documentation properties, see",h("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}),a({name:"editorialNote",title:"Editorial Notes",type:"text",description:h(Yn,{children:[u("summary",{children:"Information to aid in administrative housekeeping, such as reminders of editorial work still to be done, or warnings in the event that future editorial changes might be made."}),h("div",{children:[h("kbd",{children:["Example: doubleclick",u("br",{}),'Editorial Note: "Review this term after the company merger is complete."']}),h("p",{children:["For more information on the recommended usage of the SKOS documentation properties, see",h("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}),a({name:"changeNote",title:"Change Notes",type:"text",description:h(Yn,{children:[u("summary",{children:"Fine-grained changes to a concept, for the purposes of administration and maintenance."}),h("div",{children:[h("kbd",{children:["Example: tomato",u("br",{}),"Change Note: \"Moved from under 'fruits' to under 'vegetables' by Horace Gray\""]}),h("p",{children:["For more information on the recommended usage of the SKOS documentation properties, see",h("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:N})}})}function co(){return u("svg",{"data-sanity-icon":!0,width:"25",height:"25",viewBox:"0 0 25 25",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:u("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"})})}function lo(e,t=[]){return s({name:"skosConceptScheme",title:"Concept Scheme",type:"document",icon:co,initialValue:async(t,n)=>{if(e)return{baseIri:e};const{getClient:r}=n;return{baseIri:await r({apiVersion:"2021-03-25"}).fetch("\n *[(_type == 'skosConcept' || _type == 'skosConceptScheme') && defined(baseIri)]| order(_createdAt desc)[0].baseIri\n ")??void 0}},fields:[a({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"}),a({name:"description",title:"Description",type:"text",rows:5,description:"Describe the intended use of this scheme."}),a({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:io}}),...ao,a({name:"schemeId",title:"Identifier",description:"This scheme does not yet have a unique identifier.",type:"string",initialValue:()=>`${I(6)}`,hidden:({document:e})=>!!e?.schemeId,readOnly:({document:e})=>!!e?.schemeId,components:{input:sr}}),a({name:"topConcepts",title:"Top Concepts",type:"array",validation:e=>e.unique(),of:[c({type:"reference",to:[{type:"skosConcept"}]})],options:{sortable:!1}}),a({name:"concepts",title:"Concepts",type:"array",validation:e=>e.unique(),of:[c({type:"reference",to:[{type:"skosConcept"}]})],options:{sortable:!1}}),...t],preview:{select:{title:"title"},prepare:({title:e})=>({title:e,media:co})}})}const po=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 e=>{const n=e?.getClient({apiVersion:"2023-01-01"});if(!n)throw new Error("Client not available");const{concepts:r,topConcepts:o}=await n.fetch(`{\n "concepts": *[_type=="skosConceptScheme" && schemeId == "${t}"].concepts[]._ref,\n "topConcepts": *[_type=="skosConceptScheme" && schemeId == "${t}"].topConcepts[]._ref\n }`);return{filter:'!(_id in path("drafts.**"))\n && (_id in $concepts\n || _id in $topConcepts)',params:{concepts:r,topConcepts:o,schemeId:t}}}},ho=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 e=>{const r=e?.getClient({apiVersion:"2023-01-01"});if(!r)throw new Error("Client not available");const{concepts:o}=await r.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 path("drafts.**")) && _id in $concepts',params:{concepts:o,schemeId:t,branchId:n}}}},uo=e=>e.list().title("Taxonomy Manager").items([e.documentTypeListItem("skosConceptScheme").title("Concept Schemes"),e.documentTypeListItem("skosConcept").title("Concepts")]),fo=(e,{schemaType:t})=>{switch(t){case"skosConceptScheme":return e.document().views([e.view.component(no).title("Tree View").icon(co),e.view.form().icon(S)]);case"skosConcept":return e.document().views([e.view.form().icon(S)]);default:e.view.form()}},mo=l((e=>{const{baseUri:t,customConceptFields:n,customSchemeFields:r}=e||{};return{name:"taxonomyManager",options:e,schema:{types:[so(t,n),lo(t,r)]},plugins:[p({name:"taxonomy",title:"Taxonomy",structure:uo,defaultDocumentNode:fo,icon:co})]}}));export{oo as ArrayHierarchyInput,ro as ReferenceHierarchyInput,no as TreeView,ho as branchFilter,po as schemeFilter,mo as taxonomyManager};//# sourceMappingURL=index.esm.esm.js.map
|