import{C as d}from"./collection-nnUjKAuT.js";import"./manifest--hA2W8VB.js";const f=`The Notification Center allows to handle notifications. It works by dealing with a backend source with a simple REST API interface.

The Notification Center expects to be linked to a dataset of notifications like:

\`\`\`
type Notification = {
  _id: string
  creatorId: string
  createdAt: string
  title: string
  readState?: boolean
  content?: string
  onClickCallback?: CallbackHref
}

type CallbackHref = {
  content: content: string | {url: string, data: any};
}
\`\`\`

\`onClickCallback\` field in retrieved notifications allows to controls the navigation destination upon clicking the notification.
`,g=`Il Notification Center consente di gestire le notifiche, utilizzando una fonte di backend con un'interfaccia API REST semplice.

Il Notification Center si aspetta di essere collegato a un insieme di notifiche strutturate come segue:

\`\`\`
type Notification = {
  _id: string
  creatorId: string
  createdAt: string
  title: string
  readState?: boolean
  content?: string
  onClickCallback?: CallbackHref
}

type CallbackHref = {
  content: content: string | {url: string, data: any};
}
\`\`\`

Il campo \`onClickCallback\` nelle notifiche permette di controllare la destinazione della navigazione quando si clicca sulla notifica.
`;var m=t=>{var s;const c={};["default","href"].includes((s=t.clickStrategy)!=null?s:"default")&&(c.content={type:"string"});const o=new d({type:"object",properties:{title:{type:"string"},readState:{type:"boolean"},...c},required:["title"]});return[{url:{pathname:t.endpoint?"".concat(t.endpoint,"/own"):"/api/v1/bk-notification-center/own"},handler:async i=>{var e,n;const a=(e=t.limitQueryParam)!=null?e:"limit",l=(n=t.skipQueryParam)!=null?n:"skip",p=i.searchParams.get(a),u=i.searchParams.get(l),r=new URL(i);return r.searchParams.delete(a),r.searchParams.delete(l),p&&r.searchParams.set("_l",p),u&&r.searchParams.set("_sk",u),new Response(JSON.stringify(o.getAll(r)),{status:200,headers:{"content-type":"application/json"}})}},{url:{pathname:t.endpoint?"".concat(t.endpoint,"/own/count"):"/api/v1/bk-notification-center/own/count"},handler:async i=>{const e=new URL(i),n=o.count(e);e.searchParams.set("_q",JSON.stringify({readState:!1}));const a=o.count(e);return new Response(JSON.stringify({count:n,unread:a}),{status:200,headers:{"content-type":"application/json"}})}},{url:{pathname:t.endpoint?"".concat(t.endpoint,"/read-state/"):"/api/v1/bk-notification-center/read-state/"},method:"PATCH",handler:async i=>{const e=i.pathname.split("/"),n=e[e.length-1];if(n==="own")return o.forEach(l=>{l.readState=!0}),new Response(null,{status:204});const a=o.patchOne({_id:n},{readState:!0});return new Response(JSON.stringify(a),{status:200,headers:{"content-type":"application/json"}})}}]};const h={docLink:"https://docs.mia-platform.eu/docs/microfrontend-composer/back-kit/components/notification_center",type:"layout",label:"Notification Center",description:"Allows to handle notifications. It works by dealing with a backend source with a simple REST API interface",descriptionLong:{en:f,it:g},example:JSON.stringify({tag:"bk-notification-center",property:{endpoint:"/notifications"}}),mocks:{fetch:m},properties:{endpoint:{type:"string",default:"/api/v1/bk-notification-center",__mia_configuration:{priority:"high",attribute:!0,label:"Endpoint",description:"API endpoint for HTTP calls","schema-hint":"mia/endpoints"}},limit:{type:"number",default:10,__mia_configuration:{priority:"medium",attribute:!0,label:"Pagination limit",description:"controls pagination limit while fetching notifications"}},clickStrategy:{type:"string",default:"default",enum:["default","href","replace","push"],__mia_configuration:{priority:"high",attribute:"click-strategy",label:"On click strategy",description:"Configures what happens when a notification is clicked",enumLabels:{default:"Default",href:"External Link",replace:"History Replace",push:"History Push"}}},limitQueryParam:{type:"string",default:"limit",__mia_configuration:{label:"Limit query parameter",description:"query parameter which controls notification pagination page size while fetching data",attribute:"limit-query-param"}},skipQueryParam:{type:"string",default:"skip",__mia_configuration:{label:"Skip query parameter",description:"query parameter which controls notification pagination skip while fetching data",attribute:"skip-query-param"}},pushStateKey:{type:"string",default:"bk-notification-center",__mia_configuration:{attribute:"push-state-key",label:"Push state key",description:"key used to scope the content callback context in window.history.state when clickStrategy is 'push'. Otherwise it is neglected"}},allowExternalHrefs:{type:"boolean",default:!1,__mia_configuration:{attribute:"allow-external-hrefs",label:"Allow External Links",description:"when true, notification links can browse to external web pages and href are not checked to ensure they are relative to self-website"}},mode:{type:"string",default:"default",enum:["default","none","polling","long-polling","websocket"],__mia_configuration:{attribute:!0,label:"Mode",priority:"high",description:"strategy to implement for automatically fetching notifications",enumLabels:{default:"Default",none:"None",polling:"Polling","long-polling":"Long Polling (not impl.)",websocket:"Websocket (not impl.)"}}},pollingFrequency:{type:"number",default:1e4,__mia_configuration:{label:"Polling frequency",description:"frequency of notifications automatic fetching (in milliseconds), if mode is set to `polling`",attribute:"polling-frequency"}},customLocale:{__mia_configuration:{attribute:!1,label:"Custom Locale",description:"Custom localized texts shown as component labels",priority:"low"},type:"object",properties:{title:{type:"string",__mia_configuration:{label:"Title","schema-hint":"localized-text"}},loadingButton:{type:"string",__mia_configuration:{label:"Loading Button","schema-hint":"localized-text"}},dateFormat:{type:"string",__mia_configuration:{label:"Date Format","schema-hint":"localized-text"}},noNotification:{type:"string",__mia_configuration:{label:"No Notification","schema-hint":"localized-text"}},errorMessage:{type:"string",__mia_configuration:{label:"Error Message","schema-hint":"localized-text"}},readAll:{type:"string",__mia_configuration:{label:"Read All","schema-hint":"localized-text"}},reload:{type:"string",__mia_configuration:{label:"Reload","schema-hint":"localized-text"}},backOnTop:{type:"string",__mia_configuration:{label:"Back On Top","schema-hint":"localized-text"}}}},locales:{type:"object",additionalProperties:{__mia_configuration:{deprecated:!0,priority:"low",attribute:!1,label:"Locale translations",description:"(DEPRECATED: use Custom Locale instead)key-value list to customize components default labels. Keys are paired to either a string, which overrides language support or to a key-value map that matches a language to a translation","schema-hint":"localized-text"}}}}};var _=h;export{_ as default};
