{"mappings":"AACA,cAAc,sBAAiC;AAG/C,SAAS,mBAA+C;;;;;;;AAWxD,cAoDM,aAAa,YAAY;;;;CAI7B,AACA,UAAU,aAAa,cAAc,gBAAgB;CAErD,AACA;;;;CAKA,AACA;;;;;CAMA,AACA;CAEA,YAAY;CAIZ,UAAU,eAAe;;AAiB3B,eAAe;AACf,SAAS","names":[],"sources":["../../../../src/web-components/chip/component.ts"],"sourcesContent":["import { attr, godown, htmlSlot, styles } from \"@godown/element\";\nimport { type TemplateResult, css, html } from \"lit\";\nimport { property } from \"lit/decorators.js\";\n\nimport { GlobalStyle, cssGlobalVars, scopePrefix } from \"../../internal/global-style.js\";\n\nconst protoName = \"chip\";\nconst cssScope = scopePrefix(protoName);\n\n/**\n * {@linkcode Chip} renders a chip.\n *\n * @slot - Chip content.\n * @category display\n */\n@godown(protoName)\n@styles(css`\n  :host {\n    ${cssScope}--offset: 0%;\n    ${cssScope}--offset-x: var(${cssScope}--offset);\n    ${cssScope}--offset-y: var(${cssScope}--offset);\n  }\n\n  :host,\n  :host([contents]) [part=\"root\"] {\n    display: inline-block;\n  }\n\n  [part=\"root\"] {\n    position: relative;\n  }\n\n  [part=\"chip\"] {\n    position: absolute;\n    font-size: 75%;\n    padding: 0 0.5em;\n    user-select: none;\n    border-radius: calc(infinity * 1px);\n    transform: translate(-50%, -50%);\n    color: var(${cssGlobalVars.primaryForeground});\n    background: var(${cssGlobalVars.primaryBackground});\n  }\n\n  [part=\"chip\"]:empty {\n    width: 0.5em;\n    height: 0.5em;\n    font-size: 100%;\n    padding: 0;\n    border-radius: 50%;\n  }\n\n  [position^=\"top\"] [part=\"chip\"] {\n    top: calc(0% + var(${cssScope}--offset-y));\n  }\n\n  [position$=\"right\"] [part=\"chip\"] {\n    left: calc(100% - var(${cssScope}--offset-x));\n  }\n\n  [position^=\"bottom\"] [part=\"chip\"] {\n    top: calc(100% - var(${cssScope}--offset-y));\n  }\n\n  [position$=\"left\"] [part=\"chip\"] {\n    left: calc(0% + var(${cssScope}--offset-x));\n  }\n`)\nclass Chip extends GlobalStyle {\n  /**\n   * The position of the chip relative to its parent element.\n   */\n  @property()\n  position: \"top-left\" | \"top-right\" | \"bottom-left\" | \"bottom-right\" = \"top-right\";\n\n  @property({ type: Number })\n  value = 0;\n\n  /**\n   * If `true`, render a dot chip.\n   */\n  @property({ type: Boolean })\n  dot = false;\n\n  /**\n   * The maximum value that can be displayed in the chip\n   * Values greater than this will be displayed as `max+` by default.\n   */\n  @property({ type: Number })\n  max = 99;\n\n  formatValue(value: number): string {\n    return value > this.max ? this.max + \"+\" : value + \"\";\n  }\n\n  render(): TemplateResult<1> {\n    return html`\n      <div\n        part=\"root\"\n        ${attr(this.observedRecord)}\n      >\n        ${htmlSlot()}\n        ${this.value || this.dot\n          ? html`\n              <div part=\"chip\">${this.dot ? \"\" : this.formatValue(this.value)}</div>\n            `\n          : \"\"}\n      </div>\n    `;\n  }\n}\n\nexport default Chip;\nexport { Chip };\n"],"version":3,"file":"component.d.ts"}